Turkey, a functioning democracy and NATO’s only Muslim-majority member, was often presented as a model for the autocratic Arab Middle East by the United States. When the Arab Spring buffeted the Middle East, Turkey’s leader Recep Tayyip Erdoğan saw an opportunity to actively promote this idea among the protesters in Arab autocracies. But the Arab Spring soon turned into winter, and Erdogan’s relationship with NATO underwent a remarkable change.

While retaining its NATO membership, Turkey has become part of the Russia-led triad engaged in peacemaking in the Syrian civil war outside the purview of the United Nations. To the alarm of its NATO partners, Turkey decided to purchase Russian S-400 missiles. In addition, it is central to the TurkStream pipeline project that will carry Russian gas through Turkey to southern European destinations.

The key to understanding this phenomenon is to examine the Turkish Republic’s geopolitics and economics, singly or jointly.

Fueling it all

Domestically, the aborted military coup in Turkey in July 2016 was a defining moment in the republic’s foreign policy. As the first foreign leader to congratulate Erdogan for crushing the coup, Russian President Vladimir Putin won the Turkish leader’s heartfelt gratitude. Iran’s Foreign Minister Muhammad Javad Zarif had tweeted a message even earlier, during the initial moves by the rebellious general: “Stability and democracy in Turkey are paramount.” In a follow-up telephone conversation with Erdogan, Iran’s President Hassan Rouhani told him that the coup attempt was “a test to identify your domestic and foreign friends and enemies.”

With a population of nearly 80 million with steadily rising living conditions, Turkey has urgent need of a dependable supply of natural gas. Aside from lignite coal, Turkey has no hydrocarbon deposits. Its main sources of gas are Russia and Iran, contributing respectively 60% and 30% of the total, with the rest coming from Azerbaijan. There is a direct correlatonship between living standards and energy consumption. Because natural gas is mostly used for cooking in Turkey, its annual consumption reflects living standards

Russia’s state-owned Gazprom had become a supplier to several European nations pumped through a pipeline laid across Ukraine. To reduce its almost total dependence on Ukraine for its gas exports, Moscow came up with a plan – South Stream – to transport gas to other parts of Europe. This project advanced until the Kremlin’s capture of the Crimean peninsula of Ukraine in February 2014, when the European Union imposed economic sanctions on Russia.

This turn of event opened the door to Russo-Turkish economic cooperation. In December, Putin cancelled the South Stream project, replacing it with the $13.74 billion TurkStream gas pipeline that by 2020 will carry Russian gas to southern Europe via Bulgaria. This involved laying a pipeline under the Black Sea to emerge in Western Turkey 900 kilometers southwest to carry 15.75 billion cubic meters of gas to Europe annually. A twin pipeline was planned to deliver gas sold to Turkey.

A spat between Moscow and Ankara – when Turkey shot down a Russian jet fighter in its airspace near the Syrian border in November 2015 – did not disrupt the massive project. Russia limited its response to curtailing trade with Turkey. The following June, Turkey apologized for downing a Russian warplane which had inadvertently strayed into its airspace. Soon after receiving a congratulatory call from Putin after the abortive July coup, Erdogan flew to St Petersburg and publicly thanked his Russian counterpart. In response, Putin relaxed trade restrictions.

Syria angle

Erdogan, who had earlier joined efforts to depose Assad, also moderated his opposition to the Syrian regime of Bashar al-Assad. Instead, he focused on blocking the creation of a Kurdish enclave, planned by the Washington-backed Kurdish militia operating as the Syrian Democratic Forces along the Turkish border. That gave Putin an opening to co-opt Turkey with the aim of ending the Syrian civil war.

After hosting a meeting with Erdogan and Rouhani in Sochi on November 22, Putin said, “The militants in Syria have sustained a decisive blow and now there is a realistic chance to end the multi-year civil war.” He had conferred with Assad two days earlier. Notably on November 12, Turkey announced signing a contract for the purchase of Russian S-400 missiles, ignoring the disapproval of other NATO members, particularly the United States.

In mid-December Putin and Erdogan suggested the Kazakh capital of Astana as a venue for conducting peace talks for Syria. On December 20, Iran’s Foreign Minister Zarif joined them at Astana. Reversing past policies, Iran and Turkey found themselves on the same side in the Syrian crisis.

Energy need: Turkey’s trade partners for 2016 include diverse import and export nations; Russia’s Turk Stream pipeline could bring changes in 2020 (Source: GlobalEdge)

Turkey had been among the first countries to recognise Islamic Republic of Iran. Still its “Neither East nor West” foreign policy in the 1980s led to cool relations between the two neighbors. In the wake of the Soviet Union’s disintegration in 1991, five Muslim-majority Soviet republics – Kazakhstan, Uzbekistan, Turkmenistan, Kyrgyzstan and Tajikistan – tried to find a new identity. Washington urged them to emulate the Turkish model of secular democracy with a multi-party system and shun Iran’s Islamist model.

This advice held until June 1996 when Necmettin Erbakan, leader of the Islamic Welfare Party, became Turkish prime minister. Two months later he defied Washington’s 1996 Iran-Libya Sanctions Act by signing a $23 billion gas deal during his visit to Tehran. Turkey was to start importing Iranian gas by 1999 and continue doing so for the next 20 years in increased volumes. Though the Turkish military forced Erbakan to resign in 1997, this deal remained intact.

With the electoral victory of Turkey’s Justice and Development Party – Adalet ve Kalkınma Partisi, or AKP, a moderate successor of the Welfare Party – in November 2002, diplomatic relations between the two neighbours improved. In 2009, Ankara invested up to $4 billion in phases 6 and 7 of Iran’s South Pars gas field with reserves of 14 trillion cubic meters of gas, or 8% of the global total.

There have been periodic disagreements. When Turkey hosted the establishment of a NATO missile shield in September 2011, Iran’s President Mahmoud Ahmadinejad claimed that the shield was an American plot to protect Israel from counterattack should Israel target Iran’s nuclear facilities. Turkish Defense Minister Ismet Yilmaz retorted that the system’s aim was to secure Europe as well as Turkey. In the Syrian civil war that began in 2012, Turkey and Iran backed opposite camps. When Saudi Arabia intervened militarily in Yemen’s civil war in March 2015, Erdoğan said in an interview with France 24 TV: “We support Saudi Arabia’s intervention in Yemen,” adding that “Iran and the terrorist groups must withdraw” from the nation.

Yet he undertook a pre-planned visit on April 1 to Tehran where he signed eight economic cooperation agreements with Iran. He lamented the fact that the target of $30 billion two-way trade had become stuck at $14 billion and hoped for a pickup with the lifting of sanctions on Iran. But mutual trade in 2016 fell to $9.67 billion. He met Rouhani and, during a joint press conference, he addressed his host as “my brother,” emphasizing that Turkey and Iran should join hands to bring a peaceful outcome to the Yemeni crisis. Accompanied by Rouhani, Erdoğan met with Supreme Leader Ayatollah Ali Khamenei and proposed joint mediation efforts by Iran and Turkey in the region. Since then the Turkey-Iran entente has strengthened. In June 2017, in the crisis created by Riyadh to isolate Qatar diplomatically and economically, Iran and Turkey allied actively to help Qatar.

In all three cases, economic interests were paramount. Iran shares the gigantic Pars gas field with Qatar, and Turkey’s large construction companies help build stadiums for the 2022 FIFA World Cup tournaments.

Dilip Hiro is the author of A Comprehensive Dictionary of the Middle East (Interlink Publishing Group, Northampton, MA). His latest book is Indians in a Globalizing World: Their Skewed Rise (HarperCollinsIndia, Noida).

This article first appeared on Yale Global Online.