ANKARA - Turkey on Friday vowed to cooperate with Iran on resolving the conflict in Syria, despite Tehran and Ankara so far taking opposing sides in a civil war that has lasted more than five years.

Iranian Foreign Minister Mohammad Javad Zarif met Foreign Minister Mevlut Cavusoglu and was later to be hosted by President Recep Tayyip Erdogan, in the most significant visit by a foreign dignitary to Turkey since last month’s failed coup.

Zarif’s visit came days after a key encounter between Russian President Vladimir Putin and Erdogan, who met face-to-face for the first time since Turkey downed a Russian plane over Syria last November, straining ties.

Tehran and Moscow are Syrian President Bashar al-Assad’s main allies in the civil war, putting them at loggerheads with Turkey, which insists Assad must leave for there to be peace in Syria. But Cavusoglu said: “We will closely cooperate on these issues (on Syria) after this meeting. There are issues we agree on, especially on Syrian territorial integrity.”

“On some issues, we have different views but we have never cut dialogue. We have emphasised from the outset the importance of the constructive role Iran plays for the a permanent solution in Syria,” he added.

Analysts have speculated Moscow and Tehran may be looking for more harmony with Turkey on Syria following Erdogan’s trip to Russia.

Zarif said both Iran and Turkey wanted to see the Syrian people decide the fate of their own country. Both countries “wanted to protect the territorial integrity of Syria and that Syrian people must determine their own future”, he said.

Zarif also expressed satisfaction over the re-warming of ties between Russia and Turkey.

Despite tensions over Syria, Iran and Russia were among the first countries to give unequivocal support to Erdogan on the night of the coup. The timing of Zarif’s visit has pleased Ankara, which has hit out at the lack of Western leaders coming to Turkey since the failed coup.

Cavusoglu said Zarif was a foreign minister with whom he spoke to most frequently on the night of the coup, adding they may have talked “four or five times”. Ankara has in the past months worked to maintain a careful balance in relations with Tehran despite the dispute over Syria and Turkey’s increasingly close alliance with Iran’s regional foe Saudi Arabia.