Witnesses said as many as 50 people were killed in Lego village, 100 kilometers (62 miles) inland from the capital Mogadishu in fighting on Friday. Some of them were beheaded. A black Islamic flag was raised over the base.

Mohammed Haji, an official in the Lower Shabelle region said that militants attacked the base entrance with a suicide car bomb before gunmen began their assault. "They managed to infiltrate the entrance after the blast, it was a complex attack," said. He estimated that up to 25 combatants may have been killed.

The African Union Mission in Somalia, which is helping to fight al Shabab, did not confirm the number of troops killed in the attack.

A statement from the Somali foreign ministry called the attack "heinous and unforgivable."

German Chancellor Angela Merkel was among world leaders who condemned the attacks. She said they "show the challenges we face when it comes to fighting terrorism and Islamist extremism."

The French government also condemned the attack:

UN envoy in Libya Bernardino Leon said, "All the Libyan representatives and those from the international community want to send a message of solidarity to the four countries that have suffered," he added, referring to the attacks Friday in Tunisia, Kuwait, Somalia and France.

The assaults do not appear to have been co-ordinated, but the jihadist militia "Islamic State" (IS) has urged supporters to carry out attacks during the Muslim fasting month of Ramadan.

Nine people were killed on Wednesday after a suicide bomber drove his explosives-laden car towards a convoy of vehicles transporting Emirati diplomats in the Somali capital of Mogadishu.

jm/bk (Reuters, AFP)