The assault on the Somali National Army military camp in Barire, around 40 kilometres west of the capital Mogadishu, began with two suicide attackers detonating their car bombs before gunmen overran the base.
"There was heavy fighting this morning," said Mohamed Haji Ali, a Somali military commander, confirming the attack to local media without providing details of casualties.
Residents said the attack left bodies of government soldiers scattered on the ground while Shabaab fighters looted the base stealing vehicles and weapons.
Another resident described hearing two large blasts followed by heavy gunfire.
More From This Section
"This attack was very sophisticated with the militants raiding the base from three directions, there were two huge blasts presumably suicide bombs," said Mohamed Malim.
SNA forces had only established the military outpost at Barire recently after taking control of the town in August with the help of African Union troops.
The Shabaab claimed the raid in a statement, confirming the use of suicide bombers.
The Al-Qaeda aligned group has been fighting to overthrow successive internationally-backed governments in Somalia for the last decade and carries out frequent attacks on military, government and civilian targets.