Iran's president has said Syrian leader Bashar Assad has to remain in power to fight extremist groups like Islamic State (IS), and must not be weakened.
Hasan Rouhani told a meeting with scholars and think-tank experts that Iran would co-operate with any country that puts fighting and defeating "terrorism" as its top priority, but could not work with any government that made a change in Syria's regime its top priority.
Mr Rouhani's view puts Iran at odds with key nations which adopted a road map in Geneva in June 2012 which calls for the formation of a transitional government in Syria with full executive powers "on the basis of mutual consent".
He warned that putting regime change first would lead to an extremist takeover of Syria.
Mr Rouhani said the Syrian government needed reform but warned that if getting rid of Assad was the top goal, as soon as that happened "the terrorists will enter Damascus immediately" as well as other cities controlled by the government, and all will fall to IS.
The Iranian president's remarks came on the eve of the annual meeting of world leaders at the United Nations, where frustration is growing at the failure to launch talks to end the nearly five-year-old Syrian war.
They also follow a surprise Russian military build-up in Syria, a long-time ally, to help Assad's government combat IS, a move that has raised serious concerns in Washington. And they come on the heels of France's announcement on Sunday that it had carried out air strikes in Syria for the first time, bombing an IS training camp in the east.
Mr Rouhani said he recently met Russian officials who told him that they wanted to enter the Syrian "scene" with a renewed determination to fight "Daesh (an Arabic acronym for IS) and terrorists".
He added that "Iran and the Russians have an almost compatible mindset and opinion about this because they have the same goal of fighting and defeating terrorism."
IS already controls about two thirds of Syria and "has had the greatest safe havens and growth opportunities" in the country, he stressed.
"If we are to succeed in defeating terrorism, the government in Damascus cannot be weakened," Mr Rouhani said. "It must be able to carry on the fight."
He said "the West's opinion about Syria has changed somewhat in recent months" and the insistence that Assad must leave "no longer has that many fans". But he said there was still no agreement on how to proceed.
The Iranian leader also said it was not feasible to fight "terrorists" by military means, using helicopter gunships, missiles or aerial bombardments because they go into the heart of villages, in rural areas and in homes and "they fool people".
Months ago Iran produced a proposal to end the Syrian conflict, which has claimed more than 250,000 lives, and Mr Rouhani said it was still under discussion with some unnamed countries.