This Opinion piece first appeared in Frontline's Tehran Bureau on January 19, 2012.

After months of frosty relations, Iran and Turkey are talking again. The ostensible reason for Turkish Foreign Minister Ahmet Davutoglu's visit to Tehran two weeks ago was to try to jump start stalled nuclear talks with the so-called P5+1 group of nations. Davutoglu conveyed to Iranian chief nuclear negotiator Saeed Jalili the European Union's invitation to resume the talks in Turkey that were suspended a year ago for lack of progress.

Davutoglu's trip was a further effort to mend relations badly strained by differences over Syria and Turkey's decision to host a NATO radar system on its soil. Turkey has positioned itself as a strong regional power since the start of the Arab Awakening a year ago, while Iran hopes to maintain its regional influence by supporting Shia groups in Lebanon, Bahrain, and Iraq.

Another reason for the flurry of diplomatic activity between the Middle East's two largest powers, one that has been overshadowed by the focus on Iran and its nuclear program, is their need to cooperate on the troublesome Kurdish question.

Despite the many tensions between the two countries, Turkey and Iran share a common agenda in Iraq -- the desire to see the country remain unified. That's because both countries have sizable Kurdish minorities and both seek to stem calls by separatist Kurdish groups for more autonomy in their respective territories. Both fear that the autonomy Iraqi Kurds enjoy might lead to similar territorial claims and divided loyalties among their own Kurdish minorities. Turkey, for instance, has spent decades battling the PKK, a Kurdish group that operates out of northern Iraq, which has long sought sovereignty from Ankara. (Both the United States and European Union designate the PKK as a foreign terrorist organization.) Iran has been fighting against the PJAK, an Iranian offshoot of the PKK that also uses northern Iraq to carry out attacks against Iran.

Such is the concern in Ankara and Tehran over Kurdish irredentism that they have agreed to share military intelligence on Kurdish rebel activities along their borders. Moreover, the rapprochement has driven Turkey recently to reiterate its long-time stance that Iran has the right to enrich uranium for civilian purposes, and proclaim that it is bound only by U.N. sanctions against Iran and will not comply with unilateral American sanctions.

It is understandable, then, that the two countries have cultivated good relationships with both the central government in Baghdad and the Iraqi Kurdistan Regional Government (KRG) led by Massoud Barzani. The Turks need Barzani's cooperation in cracking down on PKK strongholds in his region. In 2009, Turkey officially recognized the KRG, invested heavily in the region, and opened consulates in KRG's capital Erbil as well as in Basra and Mosul in a tangible display of support for a unified Iraq.

Similarly, Iran has been improving ties with the KRG. On October 29, Barzani met in Tehran with Iranian Foreign Minister Ali Akbar Salehi to discuss the activities of the PJAK. Salehi expressed his government's wish to expand ties and cooperation between Iran and Iraq's Kurdistan region, specifying the areas of bilateral trade, culture, transit links, border issues, and reciprocal official visits. Davutoglu's visit to Iran comes at a critical juncture in Iraq's domestic political dynamics as Shia-Sunni tensions rise in the wake of the American withdrawal, sparked by Iraqi Prime Minister Nouri al-Maliki's announcement of an arrest warrant for Sunni Vice President Tariq al-Hashemi on terrorism charges. The crisis triggered by Maliki's move threatens a power-sharing government that includes the Shia National Alliance, the Sunni-backed Iraqiya coalition, and Kurdish parties. More and more leaders in primarily Sunni Iraqi provinces such as Diyala and Salahuddin are demanding autonomy akin to what the Kurds now possess, further fueling sectarian tensions.

These tensions threaten the survival of Iraq as a united country and pose a security threat to both Turkey and Iran. The prospect of an independent Kurdish state on its southern border, carved out from Iraq, is especially troubling for Turkey at a time of increased PKK attacks and political deadlock in Ankara's so-called "Kurdish opening."

If Iran reciprocates Turkey's gestures, as it seems inclined to do, renewed cooperation may eclipse past disagreements on Syria and the NATO radar. If Turkey continues to advocate an inclusive Iraqi government in which no single group dominates and Iran tones down its sectarian rhetoric, Iraq might then become the stage for a reinvigorated Turkey-Iran partnership rather than a source of competition between the Middle East's heavyweights. Such a scenario would be to the benefit of all parties' long-term security interests.