Demonstrators hurled stones and police fired teargas as emotions ran high at a mass rally in Ethiopia's capital commemorating 30 compatriots shot and beheaded by Islamic State militants in Libya, witnesses said.

Protesters started gathering at Addis Ababa's Meskel Square at dawn to denounce Islamic State. "We will not bow down to terrorism!" one placard carried by a young boy said. Another read: "The world must be united against terrorism."

One man at the government-organised rally, who said he was a university professor, said many in the crowd were angry that jobless Ethiopians still felt they had to travel to places like Libya in the hope of crossing over to a better life in Europe.

He also accused the authorities of clamping down on free speech. "Even the chanting (at the rally) was led by the government," he said. "We do not have the power to speak."

Ethiopia's government dismisses accusations from rights groups that it stifles critics and opponents.

The rally was called to show solidarity with families of those killed and to mark the start of three days of national morning. Scuffles erupted moments after Prime Minister Hailemariam Desalegn spoke.

When some in the crowd hurled stones, police fired a teargas canister, witnesses said. Several people were detained and at least four police officers were seen being driven away, they added.

The prime minister urged Ethiopians not to travel across the Sahara to reach Europe. "We should strengthen our resolve against any form of terrorism and extremism," he added in his speech.

Although Ethiopia's economy is growing fast, unemployment remains high. Many opt to trek across the Sahara in a bid to reach Europe via Libya, where Islamic State militants have gained a toehold after seizing large parts of Syria and Iraq.

Ethiopia has confirmed that those killed in the video, posted at the weekend, were its citizens. Family members have so far named two of them.

"I am in pain. The innocent son of a poor mother butchered like he was," said Ahaza Kasaye, the mother of one of those identified, said, propping herself up with a walking stick. "But I am heartened to see so many Ethiopians mourn him."

The killings have stunned a nation where relations between Ethiopia's Christians and Muslims have long been relatively peaceful. Muslim lawmakers in parliament on Tuesday read out verses in the Koran preaching tolerance.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.