Turkey and the Iran–Saudi Arabia proxy conflict
The involvement of Turkey within the Iran–Saudi Arabia proxy conflict has been ambiguous, and the country has supported both Iran and Saudi Arabia at times. Background

In the 19th century, the Ottomans entered into a serious conflict with House of Saud, the first Saudi state which resulted to the Ottoman–Saudi War. The war is seen in Saudi Arabia as the first attempt to create an independent state from the Ottoman Empire, while in Turkey, it is often considered to be the war against the Salafi movement. This led to a brutal military reprisal by the Ottoman rulers, which saw the destruction of the First Saudi State and the executions of many religious leaders of the Saudis. For this reason, there is an eternal enmity between the Turks and the Saudis, which is reflected by recent revisionist campaigns in both countries. The Dissolution of the Ottoman Empire following the World War I would eventually lead to the Saudi resurgence and future establishment of modern Saudi Arabia. On 22 April 1926, the First "Treaty of Friendship" between Iran and Turkey was signed in Tehran. The basic principles included friendship, neutrality and non-aggression towards each other. The agreement also included possible joint action against groups who would try to disturb peace and security or who would try to overthrow either country's government. This policy was indirectly aimed at the internal problems both countries had with their Kurdish minorities. Timeline

Turkish alliance with Saudi Arabia (1979–2013)
With the eruption of Iranian Revolution in 1979 and subsequent Iran–Iraq War, both Turkey and Saudi Arabia were the main supporters of Saddam Hussein's Iraq, albeit Turkey quietly supported Iraq and was skeptical to the Shia clergy ruling Iran despite maintaining a neutral face, while Saudi Arabia openly supported Iraq with lethal weapons and finance. In April 1979 Saudi Arabia provided financial assistance ($250 million) to Turkey to help the latter's attempts to overcome ongoing economical and financial crisis. Turkey and Saudi Arabia initially found themselves in alliance when the Arab Spring erupted, mostly because of the Syrian civil war as Ankara and Riyadh were openly opposing Bashar al-Assad, and thus Saudi Arabia and Turkey both financed various anti-Assad forces in the conflict hoping to drive the Syrian dictator out. However, Turkey also demonstrated support for Muslim Brotherhood (MB), which was opposed by Saudi Arabia, and this had created an uneasy sentiment among Riyadh. In 2013, the Egyptian coup broke out when MB member and then-President of Egypt, Mohamed Morsi, was forcibly removed by pro-Saudi Abdel Fattah el-Sisi, Turkey had condemned the move, but it was the first sign of divergence between Ankara and Riyadh. Iran had also condemned the move, beginning a rapprochement. Gradual straining of Saudi-Turkish relations (2013–2016)
In October 2014, Saudi Arabia successfully campaigned against a Turkish bid for non-permanent membership of the United Nations Security Council due to Saudi opposition to the Turkish stance on the MB. Turkey supported the Saudi Arabian–led intervention in Yemen in 2015, however, Iran condemned it. Turkey and Iran's differing geopolitical goals in Syria and Iraq have also led to increased tension and suspicion. Turkey has on multiple occasions clashed with Iranian-backed Shiite militias such as Hezbollah and Ashab al-Kahf. Anti-Iranian views have been propagated by Turkish media like Yeni Akit and Yeni Şafak due to the Iranian role during the Battle of Aleppo. Turkish rapprochement with Iran (2016–2019)
Iran was quick to condemn the 2016 Turkish coup d'état attempt, leading to improved relations between them. From January 2017 onward, Turkey has collaborated closely with Iran and Russia in the Astana talks to resolve the Syrian Civil War. Due to the 2017 Qatar diplomatic crisis, the relationship between Turkey and Saudi Arabia faced problems, with Turkey supporting Qatar against Saudi Arabia in the diplomatic dispute. The dispute also led to increased cooperation with Iran due to its support for Qatar. Geoeconomics expert M. Nicolas J. Firzli has argued that the Turkish government has sought to use the crisis to its own advantage, by advancing an expansionist Neo-Ottoman agenda at the expense of the Gulf Cooperation Council:

Saudi Arabia, in response, has threatened to impose sanctions against Turkey, and has conducted discussions with the UAE on the topic of curbing “Turkish expansionist policy”. In turn, Turkish President Recep Tayyip Erdoğan accused Saudi Arabia of being non-Islamic and heretics. Furthermore, Turkey has deployed troops to defend the government of Qatar from an attempted coup by Saudi Arabia and the UAE. In March 2018, Saudi Crown Prince Mohammad bin Salman referred to Turkey as part of a "triangle of evil" alongside Iran and the Muslim Brotherhood. On 2 October 2018, Saudi journalist and The Washington Post writer Jamal Khashoggi was killed in the Saudi Arabian consulate in Istanbul; the move was considered as a turning point on the future hostility between Turkey and Saudi Arabia. It has been widely alleged that he was killed by the Saudi government, including by Erdogan, although he has refrained from criticizing Saudi Arabia directly and has instead suggested the blame lies with Crown Prince Mohammad bin Salman. After the incident, Prince Mohammad rejected the concept of a rift with Turkey, stating, "Many are trying to … drive a wedge between Saudi Arabia and Turkey. … They will not be able to do it as long as there is a King Salman, a Mohammad bin Salman and a President Erdogan." Almost a month after Khashoggi's death, Erdogan directly accused the Saudi government of murdering the journalist. Erdogan said, "We know that the order to kill Khashoggi came from the highest levels of the Saudi government." He also said that "the puppet masters behind Khashoggi's killing" would be exposed. Yasin Aktay, a Turkish official and adviser to Erdogan believes Khashoggi's body was dissolved in acid after being dismembered. He said, "The reason they dismembered Khashoggi's body was to dissolve his remains more easily. Now we see that they did not only dismember his body but also vaporised it.”

In February 2019, Turkey refused an invitation by the United States to attend a summit in Warsaw on countering Iranian influence in the Middle East, on the grounds that it "targets one country". Neutrality and ambiguity (2019–present)
The Iranian–Turkish rapprochement suffered a massive setback when Turkey launched a military offensive against Rojava and the Syrian government. Iran, which is on good term with Turkey since the coup, began to criticize and condemn Turkey for invading Syria and violating Syrian territorial rights. Iranian foreign minister Mohammad Javad Zarif has voiced opposition to the offensive, viewing it as a violation of Syria's sovereignty. In addition, Iran's parliamentary speaker Ali Larijani canceled his scheduled trip to Turkey. Iran and Turkey's lack of trust for each other has hampered them from achieving their various economic and political goals. According to Ahval News, an analyst wrote that while Turkey and Iran are competing for influence in Central Asia, particularly in Muslim republics, it is hindering them from becoming real allies. Turkey and Saudi Arabia began to wage a proxy conflict in Sudan. Sudan was once a former ally of Iran, but has cut off relations with Iran since 2015 to support Saudi Arabia's war efforts in Yemen. However, Sudanese fear of Saudi Arabian influence facilitated then-dictator Omar al-Bashir to get closer to Turkey, resulting in the lease of Suakin to Turkish contractors. According from Turkish media, Saudi Arabia has been deeply skeptical over Turkish presence in Sudan, out of fear that Turkey is attempting to take Sudan away from Saudi influence and threaten Saudi Arabia's security. The 2020 Baghdad International Airport airstrike, where Iranian general Qasem Soleimani was assassinated by the United States, had revealed the complicated nature of the relationship between Saudi Arabia and Turkey, with both countries secretly approving the airstrike with hope to remove a grave threat from Iran to both countries' ambitions in the Middle East. However, Turkey publicly condemned the strike. In 2020, following the Israel–United Arab Emirates peace agreement that normalised Israel–United Arab Emirates relations, Iran and Turkey were among the most vocal critics against the peace treaty. In August 2020, Mossad's chief Yossi Cohen, on his statement to the Saudi, Egyptian and Emirati counterparts, had openly named Turkey as a new threat for the peace of the region, and even further single out a number of allies Turkey would gain potential support like Azerbaijan and Qatar, the former has strong relations with Israel since 1990s. Both Saudi Arabia, Israel, Greece, Egypt and the United Arab Emirates have viewed Turkish expansionism under Recep Tayyip Erdoğan represent a new danger for the Middle East since 2018, due to ongoing conflicts with Turkey in Syria, Iraq, Sudan and Libya, with Saudi expert Saud al-Sarhan viewing it as mirroring the Ottoman pan-Islamist policies in World War I. In an interview in October 2020, Saudi Prince and former Saudi ambassador to the United States, Bandar bin Sultan Al Saud, blasted the Palestinian leadership for its incompetence as well as singling Turkey, alongside Iran, accusing Ankara of abusing the Palestinian cause for Turkish profits. The Turkish government of Erdoğan has recently lashed out Saudi Arabia and other Arab states for betraying Palestine. Iran has been thought to have a multifaceted role in the Second Libyan conflict, waging in proxy warfare against Saudi Arabia. Israel has accused Iran of providing armament support to anti-Turkish warlord Khalifa Haftar in Libya. However, Iran later publicly expressed support for the Turkish military intervention in the Second Libyan Civil War. A United Nations report nonetheless revealed that Iran had supplied Haftar's forces with anti-tank missiles. On 15 February 2021, an Iranian-backed proxy group, Ashab al-Kahf, carried out a missile attack on a Turkish military base in Iraq as retaliation for a Turkish offensive against the Kurdistan Workers' Party (PKK), which is classified as a terrorist group by the US and EU, in northern Iraq. Additionally, Harakat Hezbollah al-Nujaba, another Iranian proxy, issued a warning that it would attack Turkey if it did not end its operations in Iraq. The attack was perceived as a warning from Iran to Turkey against the latter's operations against the PKK. Turkish state-owned media claimed that the attack reflected Iran's support for the group. On 23 February, Iran's ambassador to Baghdad, Iraj Masjedi, mentioned that "Turkish forces should not pose a threat or violate Iraqi soil", and criticized Turkish intentions to control Sinjar. On 27 February, Turkey's ambassador to Iraq, Fatih Yıldız, tweeted that "Ambassador of Iran would be the last person to lecture Turkey about respecting borders of Iraq". On 14 March 2021, it was reported that Turkey had sent Syrian mercenaries into Yemen to fight alongside the Saudi-led coalition

In the beginning of 2021, Turkey's leadership was especially concerned and alarmed by rapprochement between Saudi Arabia and Greece, Turkey's arch-enemy in the Eastern Mediterranean. Turkey's hopes for reconciliation with Saudi Arabia were believed to have been dashed in mid-March 2021, as Saudi F-15C fighter jets landed in the Greek island of Crete to participate in a training exercise with Greece, a move being seen as Saudi Arabia's response in kind to Turkey's policies in Saudi Arabia's sphere of influence. Role of Neo-Ottomanism
The Turkish involvement in this conflict has been by large, exploiting the difficulties of both sides to reinstate their neo-Ottomanism, especially under the Erdoğan Presidency, who is determined to begin the project in 2023. Turkey has long seen Iran's expansions as threats but also perceived Saudi Arabia's influence with a similar reception, and is seeking to build itself as an alternative replacement to both Saudi and Iranian influences, in a degree. However, the growing Turkish military, political and economic expansions have caused some concern on the Saudi and Iranian sides. Iran considers Turkish military adventurism in Syria and its growing encounter against Iran in the Levant and Iraq as a challenge, not to mention its good relationship with Azerbaijan, which is very antagonistic to Iran. Meanwhile, Saudi Arabia has also begun a systematic campaign to rewrite history, changing the Ottoman Caliphate into the occupier of Arabia; while it has also partially financed other megaprojects to counter the growing Turkish presence in Qatar, Sudan, Maghreb, Somalia, Kuwait and Oman. Turkey has been traditionally refrained from funding Islamic schools, but since the 2010s, it has increasingly funded Islamic schools and resulted in the Saudi perception that Turkey is attempting to eradicate Saudi-funded madrasah. See also
Iran–Israel proxy conflict
Iran–Turkey relations
Muslim Brotherhood
Russia and the Iran–Israel proxy conflict
Saudi Arabia–Turkey relations
Syrian civil war

References

Saudi Arabia–Turkey relations
Iran–Turkey relations
Iran–Saudi Arabia proxy conflict
2010s in Turkish politics
Military alliances involving Turkey