The militants used guns and car bombs to take control of the base and a nearby town, Barire, 50 km (30 miles) southwest of Mogadishu, in an early-morning attack.
The fighters also took 11 pickup trucks mounted with machineguns, known as “technicals”, said Abdiasis Abu Musab, al Shabaab’s military operation spokesperson.
“The other soldiers ran helter-skelter into the woods. We now control the base and the village,” he said.
A Somali military officer put the number of dead at 15; al Shabaab said 21 were killed.
The government and al Shabaab often give differing accounts of death tolls.
“There was a battalion of soldiers but it was a fierce fighting; twin suicide car bombs and hand-to-hand fighting,” Captain Osman Ali told Reuters.
“The attacked soldiers were Somali military and the Special Forces trained by the United States (US) called Danab. There were neither the African Union Mission in Somalia (Amisom) nor other foreigners there,” Ali added, referring to African Union peacekeeping troops.
Reinforcements were being sent, he said.
Al Shabaab aims to topple the government in Mogadishu and impose its own strict interpretation of Islam.
Somalia has been at war since 1991, when clan-based warlords overthrew Dictator Siad Barre and then turned on each other.
The al Qaeda-linked group was driven out of the capital in 2011, but it still carries out frequent attacks on security and government targets and African Union peacekeeping troops.
Civilians sometimes get caught in the crossfire.
So did local residents.
“First we heard two huge blasts at the base and then heavy exchange of gunfire followed. Now it looks like the fighting died down,” Ali Farah told Reuters from Barire village.
Two weeks ago, al Shabaab attacked an army base at a town near the border with Kenya.
Three weeks ago they struck another in the southern port city of Kismayu, killing a total of at least 43 people in the two attacks.
– By REUTERS