A suicide bomber has detonated an explosives-laden car at a police station in Mogadishu, killing at least eight people and wounding 35.
The car exploded only 10 metres (32 feet) in front of a security gate of a training station for government troops.
Al Shabaab, which claimed responsibility for the attack, has waged a three-year insurgency to topple the U.N.-backed interim government they consider a stooge of the West, restricting its writ to just a few blocks of Mogadishu.
Western spy agencies say the Horn of Africa country has become a haven for foreign jihadists, while critics have accused the government of not doing enough to end the insurgency.
Somali al Shabaab rebels claimed responsibility for bombs in Uganda that killed scores of people in July.
"Today we carried out a blessed car bomb attack at the so-called police camp," al Shabaab spokesman Ali Mohamud Rage told reporters. "This is a warning to our enemies and a pleasure for us."
Police, who had earlier said they suspected al Shabaab in the hit, said civilian casualties were high in the early morning strike on a busy main road that was aimed at Seredi, the police training camp about 500 metres (1,650 feet) from Mogadishu port.
"We cannot get the exact number of dead now. We are busy collecting flesh, and people are shocked here," Hassan Ali, a police officer, told Reuters.
There were likely to be more casualties since fragments of the bomb, shrapnel and wrecked car parts were flung across the road and into various buildings and houses, police said.
Two vehicles with passengers headed for the port burst into flames and several residents fled in panic, police said. A donkey and its rider both lay dead and nearby houses made of iron sheets were destroyed.
Four of those killed were suicide bombers, seven were police officers, and half a dozen were civilians, police said.
Ali said police shot at a speeding vehicle hurtling towards the gates of their training camp, before the explosion shook the area, covering it in flames and smoke.
"We fired at the car as it sped towards us, before it exploded outside our gate. Two police guards were killed."
Ali said the bombers' vehicle was a mini-lorry loaded with drums and explosives.
The African Union (AU) peacekeeping force in Somalia said it would be steadfast in its mandate despite the attack.
Analysts say the rebels likely would have ousted the interim government by now had it not been supported by the AU troops.
"This is not their first car bomb, this will never stop our mission," Barigye Ba-Hoku, their spokesman, told Reuters.
Somalia has been plagued by violence and anarchy since dictator Mohamed Siad Barre was ousted in 1991. Neighbours say Somalia is used as a shelter by Islamist militants intent on attacks in east Africa and further afield.
Tens of thousands of civilians have been killed over the past four years in fighting that has seen the rebels seize control of about half the capital and swathes of southern and central Somalia.
The International Crisis Group (ICG) has said Somalia's government is hobbled by weak leadership and urged the international community to cut its financial support to the government. The ICG suggested regional governments would be more effective in running the war-wracked country.
"The logical alternative is a more decentralised system of governance in which most power and resources are devolved to local administrations," said analyst Rashid Abdi.