The attack was the worst yet on the force of 5,000 troops from Burundi and Uganda.
Fighting in Somalia has killed more than 18,000 civilians since the start of 2007 and driven another 1.5 million from their homes.
Sheikh Ali Mohamud Rage, an al-Shabab spokesman, said the attack was to avenge the death of Salah Ali Saleh Nabhan, a Kenyan-born al-Qaeda suspect, who was killed in southern Somalia on Monday during a raid by US special forces.
“We have got our revenge for our brother Nabhan,” Rage said.
Al-Shabab, together with Hizbul Islam, has been battling government troops and the African Union (AU) peacekeepers to impose its own strict version of Islamic law across Somalia.
Somalia’s government warned on Friday that the Somali fighters had six more stolen UN vehicles primed as suicide car bombs.
Meanwhile, al-Shabab has ordered schools not to use of textbooks supplied by UN agencies and other donor agencies.
Rage told students gathered at Mogadishu’s Nasrudin mosque : “Some UN agencies like Unesco [United Nations Educational, Scientific and Cultural Organisation] are supplying Somali schools with text books to try to teach our children un-Islamic subjects.”