For two neighbors who don’t trust each other and for centuries were engaged in fierce strategic and religious competition, it is remarkable that Sunni Turkey and Shiite Iran haven’t gone to war over their border since 1639. As Turkish leaders walk a diplomatic tightrope over U.S.-led efforts to pressure Iran into abandoning a suspected nuclear-weapons program, their overriding priority is to keep it that way.

Tehran is located 1,055 miles (1,697 kilometers) from Ankara. In 2010, Turkey had a defense budget of $17.5 billion and 510,600 active armed forces personnel; Iran’s defense budget was $7 billion with 523,000 active armed forces personnel. Turkey does not have a nuclear weapons arsenal; the capacity of Iran’s nuclear program is uncertain. Charts by Everything Type Company

Relations between the two former imperial powers became particularly strained after the 1979 Iranian Revolution, which pitted a radical theocratic model of government against the fiercely secular one that Turkey embraced under Mustafa Kemal Ataturk. Turks complained frequently of Iranian perfidy and subversive activities they alleged Iran was pursuing inside Turkey, including occasional support for the separatist Kurdistan Workers’ Party, or PKK. And yet, Turkey remained strictly neutral during the 1980-1988 Iran-Iraq War and the two neighbors continued to cooperate when necessary.

So when, in 2010, some commentators and legislators in Washington began accusing Turkey of abandoning its North Atlantic Treaty Organization allies and “turning east” to join an ideologically driven “axis” with the Islamic Republic of Iran, Turks were dumbfounded. They saw the American analysis as a facile, ahistorical take on their positions vis-a-vis Iran’s nuclear program, as well as on their efforts to build bridges with Syria and Hamas.

Double Trouble

Two events in quick succession triggered the debate in Washington. On May 31, 2010, Israeli commandos boarded a Turkish ship as it sought to break through Israel’s naval blockade of Gaza. In the fight that followed, eight Turks and a Turkish-American were shot dead, triggering a bitter rupture in relations between America’s two closest allies in the region. Then, on June 9, Turkey voted against the U.S. in the United Nations Security Council, on a resolution that imposed further sanctions against Iran over its nuclear program.

To some Americans, Turkey seemed to be picking Iran’s side in its long-running struggle against the U.S. and Israel. Turks, for their part, also felt betrayed. It was Turks, rather than Israelis, after all, who died on board the Mavi Marmara aid ship. And Turkey voted against sanctions in the Security Council, because Turkish and Brazilian diplomats had only a few weeks earlier succeeded — in line with a letter from U.S. President Barack Obama — in persuading Iran to accept a nuclear-swap deal that was designed to help restart talks on the broader Iranian nuclear program. Turks believed they had scored a breakthrough. Their allies didn’t agree.

There followed a torrent of frenzied articles, in the U.S. and elsewhere, questioning Turkey’s strategic loyalties. Observers, unhappy with Turkey’s increasingly assertive and autonomous foreign policies, alleged that the country was turning its back on the West. Events seemed to bear out their long-held suspicion that Turkey’s ruling Justice and Development Party, which has Islamist roots, remains ideologically committed to an anti-Western agenda.

That Turkish Prime Minister Recep Tayyip Erdogan called Iranian President Mahmoud Ahmadinejad “a friend,” and dismissed worries about Iran’s nuclear program as “hearsay,” provided material on which to build the case. But the approach betrays a stupefying lack of interest in analyzing the underlying rationale of Turkish foreign policy on Iran, as well as a tendency to dismiss the national interests of regional powers.

Increasing Trade

Trade between the two neighbors rose to $16 billion in 2011 from $1 billion in 2000, most of it reflecting rising oil-and-gas imports by Turkey. Iran generally provides 30 percent of Turkey’s oil supply and a third of its total natural-gas imports, saving Turkey from almost total dependence on Russia. More than 70,000 Turkish trucks go through Iran to take goods to and from Central Asian republics each year. Both sides often cooperated in their fights against Kurdish separatists.

With such interests at stake, Turkey objected to the imposition of harsher sanctions against Iran. To protect valuable commercial ties, Turkish negotiators worked tirelessly to keep diplomatic options open. But to the discomfort of its Western allies, Turkey also consistently raised the issue of Israel’s undeclared nuclear arsenal, insisting that the debate over Iran’s program should be conducted with a view to a nuclear-free Middle East.

Turkey has no interest in having a nuclear-armed Iran as its neighbor. It is cognizant that this would trigger a race to acquire nuclear weapons by Iran’s foes in the Arab world. Nuclear arms, plus increasingly sophisticated missile systems, would also tilt the balance of power between two neighbors of similar size in favor of Iran.

Yet Turkey has even less enthusiasm for war, waged by either Israel or the U.S. It believes a diplomatic solution to the nuclear standoff can still be found, if the Iranians are given a return ticket to the international system and a normalization of relations with the U.S. On the other hand, the Turkish authorities increasingly are worried about the fragmented nature of the Iranian regime and the growing clout of the Revolutionary Guard Corps.

The preference for a diplomatic solution to the Iran nuclear dispute continues, even after a sharpening of the age- old competition between Iran and Turkey following the Arab revolts and the U.S. withdrawal from Iraq. These developments have triggered a rapprochement with officials in Washington and have exposed talk of a “shift of axis” for the fallacy that it is.

Competition Over Iraq

U.S. withdrawal has allowed Iran to firm its grip on Iraq, and tensions between Sunnis and Shiites are rising. Iran is a natural patron of Iraq’s Shiite majority, and despite efforts to stay above the sectarian fray, Turkey is seen as siding with Iraq’s Sunni leaders. Partly as a consequence of this trend, relations between Turkey and the Shiite-dominated government in Baghdad have deteriorated considerably and Turkish influence in non-Kurdish areas of Iraq has declined.

But the most important area of competition between the Iranian and Turkish capitals is Syria. In the course of the last nine years, Turkey made a substantial political investment in building relations with the Syrian regime — partly with an eye to luring President Bashar al-Assad away from Iran. Syria is a big prize in the regional contest for hegemony. That investment was incinerated, however, when Erdogan failed to persuade Assad to respond to protesters and open up Syria’s political system.

Forced to choose, the Turkish government sided with the mainly Sunni Syrian opposition, whose largest organization, the Syrian National Council, has since set up its headquarters in Istanbul. A commander of the Free Syrian Army is among the refugees who live in camps in Turkey. Iran, by contrast, unequivocally supports the Assad regime, which comes predominantly from the Alawite sect, and has been harshly critical of Turkey’s position.

As they wrestle with each other in Iraq and Syria, the Turkish and Iranian foreign ministers shuttle back and forth between their capitals, declaring eternal friendship. In a similar pas de deux, Turkey continues to play a role in attempting to mediate the nuclear impasse, while Iran still appears to need its neighbor’s good offices in rekindling negotiations with Western powers. As time goes by, that dance is getting harder to sustain.

* Soli Ozel is a professor of international relations at Kadir Has University and a columnist for Haberturk newspaper. This is the fifth in a series of op-ed articles about Iran, from writers in countries that have a direct interest in the escalating debate over how to rein in its alleged nuclear weapons program. Read Part 1, Part 2, Part 3 and Part 4. The opinions expressed are his own.