The leaders of Turkey and Russia pledged Tuesday to restart key energy projects and roll back sanctions, seeking to rebuild ties as Turkey looks beyond its NATO partners for support following a failed coup attempt last month.

In his first trip abroad since the attempted takeover by the military, Turkish President Recep Tayyip Erdogan openly courted Russia — in vivid contrast to recent and bitter hostilities with Moscow, especially over Syria’s civil war.

Erdogan called Russian President Vladi­mir Putin “my dear friend Vladimir” at talks in the Konstantinovsky Palace near St. Petersburg. The Turkish leader repeatedly thanked Putin for his rapid offer of aid following the coup attempt, and called for relations between the two countries to return “to their pre-crisis level, or even higher.”

“This is our principled position. We always categorically oppose any anti-constitutional actions,” Putin told journalists, referring to the attempted military takeover.

But the negotiations are likely to elevate concerns in the West over Turkey’s political direction as it employs increasingly authoritarian measures in the wake of the coup attempt.

Erdogan has criticized the West for what he viewed as tepid support after rogue military officers seized combat aircraft and fired on parliament and protesters, killing more than 250 people. He has demanded that the United States extradite a U.S.-based Turkish cleric who he says inspired the putsch.

The two presidents met face-to-face for the first time since Turkish fighter jets shot down a Russian Su-24 warplane over the Syrian border last September, bringing the regional rivals to the brink of war and sparking a political crisis.

While Erdogan and Putin emphasized their renewed economic cooperation, they avoided topics that could undercut the high-level outreach. Those included the conflict in Syria, where Moscow is backing President Bashar al-Assad and Turkey supports his enemies. Also sidestepped in public: compensation that Russia wants Turkey to pay for the death of its Su-24 pilot.

In discussions he called “constructive,” Putin said that Russia would gradually lift economic sanctions from Turkish companies, seek to resume charter flights to take tourists to Turkey, consider resuming imports of Turkish agricultural products and pursue other steps to repair economic cooperation.

Erdogan, in turn, said he would resume talks on a natural gas pipeline from Russia to Turkey and grant special status to a planned nuclear power plant that will be built by Russia.

In a climate of heightened anti-Western sentiment, Erdogan’s move to warm relations with Russia may cement Turkey’s alienation from its traditional allies, analysts say.

What we know about the failed coup attempt in Turkey

The meeting between Putin and Erdogan “is a big deal. . . . Turkish foreign policy now stands at a crossroads,” said Soner ­Cagaptay, director of the Turkish Research Program at the Washington Institute for Near East ­Policy.

“For the first time in recent memory, there is serious discussion of Turkey’s NATO membership,” he said. And some Turkish officials , he said, are questioning whether Turkey should move toward Russia.

Erdogan “could easily accomplish this pivot,” Cagaptay said, especially given the reduced state of the Turkish military. The armed forces have the strongest interest in maintaining NATO ties, he said, but are damaged after undergoing thousands of arrests since the coup attempt.

Russia slapped Turkey with harsh economic sanctions in January as punishment for the downed fighter jet, including a ban on Turkish produce and charter flights to Turkey.

Turkey had been the largest supplier of agricultural products to the Russian market, according to Crisp Consulting, a clearinghouse for Russian food marketing and logistics news. The two sides had also shelved plans for a natural gas pipeline that would run from Russia to Turkey under the Black Sea.

Even as the leaders on Tuesday discussed rolling back some of the sanctions, analysts said their ability to establish a personal relationship might be more important.

Both leaders have built a “personalized and authoritarian style of governance,” according to Asli Aydintasbas, an expert on Turkish foreign policy at the European Council on Foreign Relations. And their shared traits probably will help boost ties.

“The personal aspect is very important,” Pavel Shlykov, an analyst with the Institute of Asian and African Studies at Moscow State University, said in an earlier interview.

“The political relationship between the two countries is very dependent on the basis of personalities, on Erdogan and Putin, and the initiatives start from them,” he said.

In June, Erdogan sent a personal apology to Putin for the downed warplane. Putin had called the attack a “stab in the back by the accomplices of terrorists” — a reference to Erdogan’s support for Syria’s rebels.

But Putin accepted the apology and appeared to signal a detente.

“Now the flow of events has swayed Erdogan even closer,” said Sergey Karaganov, an influential Russian foreign policy thinker and a dean at Moscow’s Higher School of Economics.

“Building relationships with Russia for him is a normal step,” Alexei Malashenko, an analyst at the Moscow Carnegie Center, said of Erdogan. “And I’m sure Erdogan will repeat [to Western leaders]: ‘If you refuse to help me or respect me, don’t forget about my good relations with Putin.’ ”

Cunningham reported from Istanbul. Zeynep Karatas in Istanbul contributed to this report.