A visit to Iran by Turkey's Foreign Minister Mevlut Cavusoglu on Wednesday highlighted their opposing views on the Syrian conflict, with both countries saying dialogue was needed to close gaps.
Cavusoglu's visit came as Syrian Prime Minister Wael al-Halaqi was in Tehran for talks with Iranian leaders, during which he thanked them for their staunch support.
The gulf between Iran, Syrian President Bashar al-Assad's principal regional ally, and Turkey, which has supported Sunni rebels seeking to overthrow him, was underlined by Cavusoglu.
"We consider the Assad regime as not having legitimacy," he said at a joint press conference with his Iranian counterpart Mohammad Javad Zarif.
"Iran and Turkey have different positions but our countries are cooperating to find a common solution in Syria," Cavusoglu added.
Zarif said that although Iran and Turkey had differences, they nevertheless faced "common enemies" and there was a "need to bring our positions together to stop terrorists entering Iraq and Syria."
"We all want peace established as soon as possible in Syria without foreign interference," he added.
Iran has strongly backed Assad, sending money and military advisers to Damascus as well as supporting him politically in the face of widespread international opposition.
The Syrian premier thanked Iran for its "unreserved support" during talks with First Vice President Eshaq Jahangiri, the official IRNA news agency reported.
Signup to our newsletter and follow us on Facebook and Twitter!
"Iran and Syria stand side by side in the battle against terrorism," Halaqi said.
Halaqi, who arrived in Tehran on Monday, also held talks with President Hassan Rouhani.
"For four years, the Syrian army and people have valiantly resisted the plots and terrorist groups," Rouhani said.
"Today, world public opinion has understood that the Syrian army and people are fighting terrorist groups and foreign plots," the government website quoted him as saying.
Damascus and its allies deride all Syrian rebel groups as "terrorists" and have accused Turkey and Gulf Arab states Qatar and Saudi Arabia of helping to spawn the jihadist Islamic State group through their support.
But speaking to reporters at the Turkish embassy, Cavusoglu denied that Ankara had turned a blind eye to the passage of foreign jihadists to Syria and Iraq.
"More than 7,000 people have been barred from leaving Turkey and slightly more have been deported," the Turkish minister said.
He also denied that Turkey had allowed black market oil to be smuggled from IS-controlled areas providing the jihadists with one of their main sources of revenue.
"Since the start of the year, some 80 million litres of black market oil have been seized," he said.