Delegates at the Non-Aligned Movement in Tehran, Iran
Egypt's president has told a summit of the Non-Aligned Movement (NAM) that the Syrian uprising is a "revolution against an oppressive regime".
Mohammed Mursi, making the first visit to Iran by an Egyptian leader since 1979, said the movement had an "ethical duty" to support the uprising.
His comments sparked a walkout by the Syrian delegation.
Syria's Foreign Minister Walid Muallem said Mursi's speech "incites continued bloodshed in Syria".
Egypt has been holding the rotating NAM presidency and Mursi was handing the duty over to Iran during his visit.
He used his speech to tell delegates of the 120-member body: "Our solidarity with the struggle of the Syrian people against an oppressive regime that has lost its legitimacy is an ethical duty, as it is a political and strategic necessity.
"We all have to announce our full solidarity with the struggle of those seeking freedom and justice in Syria, and translate this sympathy into a clear political vision that supports a peaceful transition to a democratic system of rule that reflects the demands of the Syrian people for freedom."
He compared the anti-government movement in Syrian to the Palestinians, saying they were both "actively seeking freedom, dignity and human justice", and said Egypt was "ready to work with all to stop the bloodshed".
The BBC's Iran correspondent, James Reynolds, says Tehran's hope for the summit was to show the West the Islamic Republic had plenty of friends elsewhere, but Mr Mursi's comments would certainly have upset the hosts.
However, he says not everyone in Iran would have noticed, as one Iranian state TV channel mistranslated Mr Mursi's words into Persian, giving the impression that president was actually speaking in support of the Syrian government.
Syria's delegation walked out of the conference room when Mursi began speaking, Egyptian and Syrian media reported. Iranian media said they had simply left to conduct an interview.
Muallem said Mursi's comments "violated the traditions of the summit and are considered interference in Syrian internal affairs".
He accused Mursi of "inciting continued bloodshed in Syria".
Mursi's visit was the first by an Egyptian leader to Iran since the 1979 Islamic Revolution, when Iran cut ties with President Anwar Sadat's administration over its signing of a peace treaty with Israel.
After his speech, Mursi met Iranian President Mahmoud Ahmadinejad.
Iranian Deputy Foreign Minister Hossein Amir Abdollahian said the presidents had discussed bilateral ties and "emphasised the need to solve the Syria crisis via diplomacy and to prevent foreign intervention".
Mursi left Tehran shortly afterwards, Iranian media said.
UN Secretary General Ban Ki-moon, who is attending the summit, said Syria was facing a long-term civil war, and warned that "those who provide arms to either side in Syria are contributing to the misery".
"The situation cannot be resolved with the blood and the bodies of more than 18,000 people and counting. There should be no more bullets and bombs. I urge all parties in the strongest possible terms to stop the violence now," he said.
Ban's acceptance of Tehran's invitation to the summit was described by the US State Department as "strange", but the South Korean has not shied from drawing attention to the Iran's human rights record, telling a press conference he had "serious concerns".
Nuclear disarmament is also on the agenda of the talks and in his speech to delegates on Thursday, Ayatollah Khamenei said that, contrary to the view held in the West, Iran was "never seeking nuclear weapons".
He said such weapons were "a major and unforgivable sin", but that Iran would "never give up the right to peaceful nuclear energy".
The ayatollah also criticised the "illogical" structure of the United Nations Security Council, saying it enabled the US to impose its "bullying manner" on the world, Reuters reports.
"The UN Security Council has an irrational, unjust and utterly undemocratic structure, and this is an overt dictatorship," he said.