The failed Horn of Africa state has not had an effective central government for nearly two decades, leading to the rise of warlords, heavily armed criminal gangs and pirates who have been terrorising shipping off its long coastline.
Western security agencies say the country has also become a safe haven for Islamist militants, including foreign jihadists, who are using it to plot attacks across the region and beyond.
In a statement dated last Friday but seen by Reuters on Monday, al Shabaab and the smaller Kismayu-based Kamboni rebel group said they had put their differences behind them.
We have agreed to join the international jihad of al Qaeda ... We have also agreed to unite al Shabaab and Kamboni mujahideen to liberate the Eastern and Horn of Africa community who are under the feet of minority Christians, the statement said.
We have united to revive the military strength, economy and politics of our mujahideen to stop the war created by the colonisers, and to prevent the attacks of the Christians who invaded our country.
In this context, Christians is believed to refer to Ethiopian troops who invaded Somalia in late 2006 and then withdrew, and to Ugandan and Burundian peacekeepers serving with the African Union's AMISOM force in Mogadishu.
The statement appeared to have been signed by senior rebels including Sheikh Hassan Turki, commander of the Kamboni militia, and the reclusive al Shabaab leader, Ahmed Abdi Godane.
Security experts believe Shabaab's total manpower is no more 5,000, while there are a few hundred Kamboni militiamen.
In the capital Mogadishu, insurgents fired mortar bombs at the presidential palace overnight, prompting return fire by troops there that killed at least 16 people, medical officials and residents said.
ARTILLERY BATTLES IN MOGADISAHU
Violence has killed at least 21,000 people in the failed Horn of Africa nation since the start of 2007 and driven another 1.5 million from their homes, helping trigger one of the world's worst humanitarian emergencies.
Al Shabaab rebels routinely fire at the white-washed hilltop Villa Somalia palace compound from other parts of Mogadishu. Troops at the palace often launch shells back.
Residents and medical officials said several bombs struck around the city's northern Suqa Holaha, or livestock market.
At least 16 people died and 71 others were wounded in four districts of Mogadishu, Ali Yasin Gedi, vice chairman of the Elman Peace and Human Rights Organisation, told Reuters.
At an African Union summit in the Ethiopian capital on Friday, Somalia's Foreign Minister Ali Jama' Jangeli called for more AU troops to help about 5,000 peacekeepers from Uganda and Burundi who are based in the Somali capital. [ID:nLDE60S0IN]
His Kenyan and Sudanese counterparts backed the call. Djibouti has said it would send 450 soldiers soon.
On Sunday, al Shabaab spokesman Sheikh Ali Mohamud Rage called on Djibouti to reconsider its decision.
We warn the Djibouti government and strongly recommend that it not send its troops here, otherwise there will be bad consequences for it, Rage told reporters in Mogadishu. (Additional reporting by Sahra Ahmed in Nairobi; Editing by Daniel Wallis and Giles Elgood)