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 Mr Mursi's speech "incites continued bloodshed in Syria".
Egypt has been holding the rotating Nam presidency and Mr 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 Syria 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 Mr Mursi began speaking, Egyptian and Syrian media reported. Iranian media said they had simply left to conduct an interview.
Mr Muallem said Mr Mursi's comments "violated the traditions of the summit and are considered interference in Syrian internal affairs".
He accused Mr Mursi of "inciting continued bloodshed in Syria".
Mr 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, Mr 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".
Mr 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.
Mr 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.
Mr Ban responded to the ayatollah's statement by calling on Iran to build confidence in its nuclear ambitions by co-operating fully with the Security Council over its nuclear programme.
He also rebuked Tehran for its hostility towards Israel, saying: "I strongly reject threats by any member states to destroy another or outrageous attempts to deny historical facts such as Holocaust."
However, Mr Ban's comments were also altered on Iranian state TV.
IRTV1 removed all references to Israel and the Holocaust, while rolling news channel IRINN's translation was: "I, as the secretary-general, cannot accept that threats or improper words are used in the political scene and create a situation which we cannot control."
IRINN's translation of Mr Ban's comments on the nuclear issue wrongly stated that he had noted that "the Islamic Republic of Iran's co-operation with the International Atomic Energy Agency has been constructive, effective and positive".