Mortar shells were raining down near the presidential palace in Mogadishu just hours after the Somali president resigned on Monday.

President Abdullahi Yusuf announced his resignation to parliament on Monday, saying that the country had lost control to Islamic insurgents and he could no longer fulfil his duties.

Yusuf said that he could not unite Somalia's leadership to make any progress in the war-torn country.

"Most of the country is not in our hands," Yusuf said. "After seeing all these things I have finally quit."

"When I took power I pledged three things," Yusuf said in his address, which was broadcast on radio across the country.

"If I was unable to fulfil my duty I will resign. Second, I said I will do everything in my power to make government work across the country. That did not happen either. Third, I asked the leaders to co-operate with me for the common good of the people. That did not happen," he said.

The Islamic insurgent group al-Shabab has made dramatic territory gains over recent months and now controls most of the country.

Al-Shabab released a statement after Yusuf's resignation, calling it shameful.

Analysts have suggested that Yusuf's resignation could result in more political chaos and violence while various militias jockey for power.

Only hours after Yusuf broadcast his resignation on state radio, violence erupted further in Mogadishu.

Parliament to choose new leader

The parliament Speaker will stand as acting president until Somalia can hold elections. Parliament is expected to elect a new leader within 30 days.

Yusuf's four-year-old administration, backed by the United Nations, has only brought some control to Baidoa and pockets of Mogadishu.

His position has been in doubt since parliament blocked his attempt to fire Prime Minister Nur Hassan Hussein earlier this month.

Ethiopia also plans to withdraw its troops by the end of December, leaving the government even more vulnerable to insurgents.

Thousands of civilians have been killed or maimed by mortar shells, machine-gun crossfire and grenades in near-daily fighting in this arid Horn of Africa country.

Somalia has been ravaged by violence and anarchy since warlords overthrew dictator Mohamed Siad Barre in 1991 and then turned on one another. The current transitional government was formed with UN help in 2004.

The UN says Somalia has 300,000 acutely malnourished children, but attacks and kidnappings of aid workers have shut down many humanitarian projects.

The lawlessness also has allowed piracy to flourish off the coast.

Human rights groups have accused all sides in the conflict — Islamic insurgents, the government and troops from neighbouring Ethiopia who are here supporting the administration — of committing war crimes and other serious abuses for indiscriminately firing on civilian neighbourhoods.

The U.S. State Department says al-Shabab's leaders have links with al-Qaeda and are harbouring men who conspired to blow up American embassies in Tanzania and Kenya 10 years ago, killing hundreds.

With files from the Associated Press