Iranian President Hassan Rouhani held talks in Ankara on Wednesday with his Turkish counterpart Tayyip Erdogan ahead of a three-way summit with Russia on the Syrian conflict.
The three countries are working together to try to reduce the violence in Syria despite supporting opposing sides in the war. Russia and Iran are Syrian President Bashar al-Assad's strongest backers, while Turkey supports anti-Assad insurgents.
Rouhani said before leaving Iran that foreign forces operating in Syria without approval from the Damascus government should leave - a reference to Turkey and the United States.
Turkey is waging an offensive in northwestern Syria against the Kurdish YPG militia and has pledged to extend its campaign to the country's northeast. Damascus has described the offensive as an illegal invasion.
"Iran believes that the presence of foreign forces in Syria without authorisation of the Syrian government is illegal and must be halted," Iranian state television quoted Rouhani as saying in Tehran on Tuesday night.
He said Wednesday's meeting with Erdogan and Russian President Vladimir Putin would discuss reconstruction in Syria as well as work on a new constitution, part of a plan for a political solution to end the seven-year-old war.
Despite their differences Iran, Russia and Turkey are three of the major powers involved in a conflict whose course has been largely defined by foreign interventions, and their influence could increase further if the United States pulls out.
US President Donald Trump said on Tuesday he wanted to get US forces out of Syria but offered no timetable, as his advisers warned of the hard work left to defeat Islamic State and stabilise areas recaptured from the hardline militant group.
Trump told a news conference the United States would "not rest until ISIS is gone", but he also suggested that victory was imminent.
"It's time," Trump told reporters, when asked if he was inclined to withdraw US forces.