Al Shabaab Islamist militants attacked two Somali National Army bases on Saturday and the army said there had been casualties on both sides but it was now in control of the bases.
The bases, located about 100 km (60 miles) southwest of the capital Mogadishu, were struck by two explosions, witnesses said. A third explosion targeted a convoy of troops rushing to the bases from the capital after the attack, they added.
Hussein Nur, a military officer, said the army lost "several" soldiers in the attack on Bariire and Awdhigle bases, without giving a precise number.
The army sent in reinforcements from other stations, who killed an unidentified number of attackers in the ensuing fight, he told Reuters.
The army was now in control of both bases and the surrounding areas, he said, adding, "We are pursuing the militants in the surrounding jungle".
Al Shabaab said it had launched a vehicle-borne suicide bomb attack on the Bariire base while simultaneously attacking the nearby Awdhigle base with a car bomb and fighters, to prevent troops stationed there from reinforcing Bariire.
"We overran Bariire base, burnt three military vehicles and took two vehicles," Abdiasis Abu Musab, al Shabaab's spokesman for military operations, told Reuters, referring to a brief occupation of Bariire.
A third vehicle-borne explosive device hit a convoy of government troops racing from Mogadishu with reinforcements, he said. He also said there had been casualties on both sides in the attacks.
Militants from al Shabaab, which is linked to al-Qaeda, have waged years of attacks and levied tolls on trade in a campaign to introduce strict religious law.