President Mohamed Morsi uses speech in Iran, which is key sponsor of Syrian regime, to assert Cairo's regional ambitions

Egypt's president Mohamed Morsi has said that the "oppressive" Syrian regime had lost all legitimacy, in a blistering speech in Tehran that provoked the Syrian delegation to storm out and amounted to a stunning rebuke to his Iranian hosts.

During the first visit by an Egyptian leader to Tehran since the 1979 Islamic revolution, Morsi said the world had an "ethical duty" to support Syria's rebels.

"Our solidarity with the struggle of the Syrian people against an oppressive regime that has lost legitimacy is ... a political and strategic necessity," he said.

"We all have to announce our full solidarity with the struggle of those seeking freedom and justice in Syria. [We should] 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."

Morsi's comments to a meeting of the 120-nation Non-Aligned Movement in Tehran amounted to a verbal handgrenade tossed at Iran's shocked leadership. Iran is the key regional sponsor of Syria's embattled president, Bashar al-Assad, and one of his few remaining international allies.

The remarks are also a bold assertion of post-revolutionary Egypt's renewed regional leadership ambitions. With the Middle East now dividing sharply along sectarian lines, Morsi has thrown his weight behind a powerful group of Sunni states including Saudi Arabia, Qatar and Turkey that support Syria's rebels – with only Shia Iran, evermore isolated, backing Assad and his Shia Alawite-led regime.

Syria, predictably, responded with fury. Its foreign minister, Walid al-Moallem, walked out. Damascus accused Egypt of interfering in its internal affairs and instigating bloodshed. In his own speech, Iran's supreme leader, Ayatollah Ali Khamenei, failed to mention the 17-month Syrian conflict, while Iran's state-run media blanked out Morsi's criticism of Assad.

Morsi, a moderate Islamist, has proposed that Iran take part in a four-nation contact group including Egypt, Turkey and Saudi Arabia that would mediate in the Syrian crisis. Morsi declared: "The bloodshed in Syria is the responsibility of all of us and will not stop until there is real intervention to stop it. The Syrian crisis is bleeding our hearts."

Morsi was apparently referring to diplomacy rather than any potential foreign invasion. He also hailed both Syrians and Palestinians for their "brave" struggle against oppression. He later met Iran's President Mahmoud Ahmadinejad.

Analysts said the week-long summit had not been the smooth diplomatic triumph Iran might have hoped for.

"The Iranians rolled out the red carpet for Morsi. But he didn't follow the Iranian script. It was embarrassing for the Iranians," said David Hartwell, senior Middle East analyst at IHS Jane's, adding: "The non-aligned movement tries to be fairly anodyne and focused on anti-imperialism. But Syria has made it problematic. Egypt also views Iranian influence in Syria, Lebanon and the Palestinian territories as particularly unhelpful. It sees it as an Iranian/Shia attempt to spread influence in the region."

Of Morsi, he said: "We are learning about him. We don't know what his foreign policy is going to be."

Morsi is the first Egyptian leader to visit the Iranian capital since the 1979 Islamic revolution. Egypt and Iran fell out over Cairo's support for the Shah and its peace deal with Israel. Despite recent improvements, neither has upgraded ties to ambassadorial level.

Iran, meanwhile, faces diplomatic isolation and sanctions because of its alleged nuclear programme.

On the ground in Syria, fighting continued on Thursday. Opposition activists said rebels had shot down a government warplane over the northern province of Idlib, the second time in a week rebel fighters claimed to have brought down an aircraft. One video appeared to show a pilot parachuting to the ground. A subsequent video showed his dead body.

Government shelling continued in several parts of the country, with residents in Kafr Batna, in the Damascus suburbs, reporting heavy bombardment.

"The Syrian regime is attacking us with mortars and helicopters. Today there are lot of soldiers and armoured vehicles massing up at the entrance to Kafr Batna. They might storm the district at any moment," one resident, Rima Sami, told the Guardian via Skype. Sami said all the bakeries were shut and the shelling had made it impossible for the Free Syrian Army to smuggle in food.

Human Rights Watch said government forces had dropped bombs and fired artillery at or near at least 10 bakeries in Aleppo province over the past three weeks, killing and maiming scores of civilians who were waiting for bread.

The attacks were at least recklessly indiscriminate and the pattern and number of attacks suggested government forces had been targeting civilians, it said. Both reckless, indiscriminate attacks and deliberate targeting of civilians are war crimes.

One attack in Aleppo on 16 August killed up to 60 people and wounded more than 70. Another attack in the city on 21 August killed at least 23 people and wounded 30.

"Day after day, Aleppo residents line up to get bread for their families, and instead get shrapnel piercing their bodies from government bombs and shells," said Ole Solvang, emergencies researcher at Human Rights Watch who has just returned from Aleppo. "Ten bakery attacks is not random – they show no care for civilians and strongly indicate an attempt to target them."