Al Shabaab fighters attacked a remote Somali army base northwest of the capital Mogadishu on Tuesday, killing several government soldiers, officials and the militants said.
The Islamist group, which has launched several attacks there in the last few years, said it had seized control of the entire town of Goofgaduud.
"We have captured Goofgaduud. We killed 16 soldiers in the fighting," said Sheikh Abdiasis Abu Musab, Al Shabaab's military operation spokesman.
Government and military officials were not immediately able to confirm the seizure of Goofgaduud, which lies about 250 km (160 miles) northwest of Mogadishu.
"Al Shabaab attacked our base in Goofgaduud in the morning and ambushed other forces that were sent for reinforcement," said Mohamed Aden, a military official in the region.
"We lost at least seven soldiers and one military truck was burnt," he told Reuters.
Al Shabaab's casualty figures and those announced by officials often differ.
The group, which once ruled much of Somalia, has been fighting for years to impose its strict interpretation of Islam on Somalia.
African Union and Somali troops have driven it from urban strongholds and ports but they have often struggled to defend smaller, more remote areas from attacks.
Since losing large swathes of territory to the AU peacekeepers supporting the U.N.-backed government, the insurgents have frequently launched raids and deadly attacks in Mogadishu and other regions controlled by the federal government.
On Monday, at least eight people were killed after a suicide bomber rammed a car laden with explosives into a cafe in central Mogadishu.
Somalia has been mired in conflict since 1991, when clan-based warlords overthrew Siad Barre and then turned on each other.