Turkey and Iran said on Friday they had common concerns about the increasingly sectarian nature of Syria's civil war, signalling a thaw in a key Middle Eastern relationship strained by stark differences over the conflict.
Iran has been a firm ally of Syrian President Bashar al-Assad since the start of the 32-month-old uprising against him, while Turkey has been one of his fiercest critics, supporting the opposition and giving refuge to rebel fighters.
But the election in June of President Hassan Rouhani, a relative moderate who says he wants to thaw Iran's ties with the West, and shared concern over the rise of al Qaeda in Syria, have spurred hopes of a rapprochement.
"Sitting here together with the Iranian foreign minister you can be sure we will be working together to fight these types of scenarios which aim to see a sectarian conflict," Turkish Foreign Minister Ahmet Davutoglu told a conference in Istanbul.
Iranian Foreign Minister Mohammad Javad Zarif, who held talks with President Abdullah Gul in Istanbul and Prime Minister Tayyip Erdogan in Ankara, echoed the comments, saying sectarian unrest posed an even greater risk than chemical weapons.
"If the flames of sectarianism rage in the Middle East, you will see the results in the streets of London, New York, Rome and Madrid," he told the conference.
While deep divisions remain between Ankara and Tehran over the conflict in Syria, particularly over the role of Assad in any transitional government, diplomats and government officials say both sides want to mend a relationship which could be key to wider diplomatic efforts towards a solution.
Zarif said there was common ground on many issues, including the need for Syrians to decide their own fate at the ballot box, and the differences were largely over methods rather than goals. Davutoglu said he would visit Tehran later this month.
"Both Iran and Turkey are at a point where they think they can work together on Syria," a senior Turkish official said.
"Both countries believe the situation needs an urgent solution. But the big question is how," he told Reuters.
Following talks with Erdogan, Zarif reiterated that Iran would be willing to take part in a long-delayed international peace conference on Syria in Geneva, if invited.
Arab and Western officials told Reuters this week that international powers were unlikely to meet their goal of convening the "Geneva 2" talks this month, largely due to differences over who will represent the opposition.
Turkey has long argued that Iran and Iraq, another neighbour with whom Ankara has been trying to mend fences, should be involved in the talks if they are to be credible.
Tehran's desire to participate in a June 2012 meeting on Syria hosted by the United Nations in Geneva was a major bone of contention between Washington and Moscow, Assad's key ally.
"For Geneva 2 to be meaningful there must be a clear political strategy and there must be Russia and Iran at the table. Both of them must be included and so must Iraq," a source close to the Turkish government said.
With al Qaeda-linked groups such as Jabhat al-Nusra and the Islamic State of Iraq and the Levant (ISIL) taking territory in parts of northern Syria near Turkey's border in recent weeks, pressure for a resolution has been mounting.
"We may have disagreements but if we can't present a common position over the future of the Middle East, over sectarian clashes, we would all have to bear the consequences of this," Davutoglu said.