Turkey's full-throttled support for Azerbaijan during recent hostilities with Armenia reflects a larger drive by President Recep Tayyip Erdoğan to assert his country's influence in its sprawling neighborhood.
In recent years, Erdoğan has undertaken a more aggressive foreign policy across the Middle East, north Africa and the eastern Mediterranean, frustrating Turkey's traditional Western allies. Many of these moves have put it at odds with Russia.
The outbreak of fighting in July between Armenia and Azerbaijan has added the South Caucasus to the expanding geography of Turkey's self-assigned strategic backyard - and further raised the potential for tension with Russia, which has a mutual defense treaty with Armenia.
Following the clashes - the heaviest fighting between the two former Soviet republics since 2016 - Turkey has taken an unusually assertive posture in the region to back its ally, Azerbaijan. It offered to supply it with weapons, and the two sides have held several high-level military and diplomatic visits and carried out expanded joint military exercises.
Erdoğan's rhetoric has also been harsher than in the past. He has called Armenia "an invader" and vowed that its actions would not go unanswered. In a veiled swipe at Russia, he claimed the attack "was beyond Armenia's caliber."
Azerbaijan has been a Turkish ally since gaining independence with the collapse of the Soviet Union. The two countries share ethnic and linguistic ties, and officials from both frequently recite the refrain that they are "one people, two states."
Still, Ankara's support for Baku had been tempered by its view of the south Caucasus as Russia's sphere of influence.
Turkish officials have implied that the July fighting, which took place on the border between Armenia's Tavush and Azerbaijan's Tovuz regions, threaten a key Azerbaijani transportation and energy corridor with Turkey.
Energy is a cornerstone of the relationship. Azerbaijan supplies Turkey with nearly a fifth of its natural gas imports, as well as Caspian Sea oil to the hub of Ceyhan on the Mediterranean coast, through pipelines that traverse Tovuz.
"This is a very core security issue for Turkey for energy security," a senior Turkish energy ministry official told reporters in Istanbul on condition his name was not used. "We will take any relevant measures to continue" oil and gas flows from Azerbaijan.
Russia dominates Turkish imports of oil, gas and coal, and a decades-old natural gas contract expires next year. The energy ministry official said Turkey is now seeking far more competitive terms in its negotiations with Russia.
"From the Turkish government's perspective, the recent escalation between Azerbaijan and Armenia was the result of Armenia's - backed by Russia - attack against Azerbaijani-Turkish energy projects, namely the Baku-Ceyhan oil pipeline, assuming that Russia might aim to disrupt the energy supplies from Azerbaijan to Turkey and instead keeping Turkey dependent on Russian energy resources," said Diana Yayloyan, a research associate at the Ankara-based think tank TEPAV.
"This is a dangerous narrative since it aims to present Armenia as an unpredictable destabilizer in the region - a narrative that Azerbaijan is gladly promoting," she said.
The top foreign policy adviser to Azerbaijani President Ilham Aliyev, Hikmet Hajiyev, attributed Turkey's sharp response in part to the potential threat posed to infrastructure projects linking Turkey and Azerbaijan. That "stronger position was crucially important for Azerbaijan," Hajiyev told reporters in Istanbul at a September 7 briefing.
Political developments at home have also influenced Turkey's strategic thinking in the Caucasus.
Turkey severed ties with Armenia in 1993, during a war with Azerbaijan over the territory of Nagorno-Karabakh, a breakaway majority-ethnic-Armenian part of Azerbaijan.
A U.S.-backed effort to restore those diplomatic ties a decade ago withered on the vine. There is even less appetite for rapprochement now in Turkey, where Erdoğan has stoked nationalist sentiment to shore up support among voters hit hard by a deep economic slowdown, and to maintain his coalition with an ultra-nationalist party that opposes reconciliation with Armenia. The century-old genocide of ethnic Armenians in the Ottoman Empire also poisons the relationship between the two sides.
Erdoğan "has sought to keep a nationalist narrative at the forefront out of concern for internal politics as much as foreign policy," said İlhan Uzgel, a professor of international relations at Ankara University.
In just the last year, Erdoğan has sent soldiers to Iraq, Syria and Libya and dispatched warships to accompany a research vessel hunting for hydrocarbons in Mediterranean waters that international law says are Greek. These missions are reshaping Turkey into an independent global power, he has said.
"Turkish foreign policy has become extremely militarized in recent years [and its] military support for Azerbaijan indicates a preference for confrontation over diplomacy," Uzgel said.
Engagement in the Caucasus would bring NATO member Turkey into yet another potential zone of contention with Russia, with which it maintains complex, frequently shifting relations.
While Russia and Turkey are on opposing sides in Libya and Syria, they have learned to navigate a partnership because of the advantages it bestows, including energy supplies, weapons procurement and diplomatic leverage with the West, Uzgel added.
In the Caucasus, Russia is Armenia's main backer and keeps an army base there that serves as a bulwark against Turkey, and Russian troops patrol the Armenia-Turkey border. Russia also maintains close ties with Azerbaijan, supplying the latter with the bulk of its military hardware, but Azerbaijan-Russia tensions have spiked, with Aliyev publicly accusing Russian President Vladimir Putin of shipping arms to Armenia in the wake of the fighting.
In spite of Erdoğan's suggestion of a Russian hand behind the July fighting, Hajiyev said that Baku doesn't blame Russia.
"We believe it took Russia by surprise," Hajiyev said. He credited Russian diplomacy for restoring relative calm. "We do not have any intention to reassess our relations" with Moscow.
Azerbaijan sees Russia as the key player in resolving the conflict over Nagorno-Karabakh, which has defied decades of international meditation and has failed to capture the attention of the current U.S. administration.
"It's our belief that it should be a strategic objective of Russia to see more de-escalation and a resolution of the Armenia-Azerbaijan conflict," said Hajiyev. Russian and Turkish cooperation "is a partnership that can bring security and stability to our region, especially ... for the durable lasting resolution of the conflict."
Others are less sanguine. Turkey's swift and severe condemnation of Armenia during the latest skirmishes is likely to bury the notion it can act as an arbiter, said Yayloyan.
"With its unprecedented harsh rhetoric and unilateral support of Azerbaijan, Turkey has not only further diminished the chances of normalizing ... its relations with Armenia, which are almost nonexistent, but also discredited itself as a potential participant ... in the process of the peaceful settlement of the Nagorno-Karabakh conflict," she said.