Simultaneous large explosions were heard in and around two Somali army bases, with the military confirming at least nine of its people killed but asserting "heavy losses" among the attackers.
The al-Shabaab extremist group claimed responsibility.
Residents said the attacks on Saturday occurred in Bariirre and Awdhegleh villages of Lower Shabelle region, 75 kilometres south of the capital, Mogadishu.
Speaking to local media, General Odawa Yusuf Ragheh, the commander of the Somali National Army, confirmed the twin attacks but said al-Shabaab had been repulsed with "heavy losses" among the extremists.
"They even left some of the bodies of their slain commanders," he added, saying his forces were still chasing the fleeing fighters.
General Mohamed Tahlil Bihi, the commander of the infantry forces of the government, told the Associated Press that "we lost nine of our soldiers and 11 others got wounded from our side".
"From the Shabab, we killed 60 of their militias on one spot and 17 others near the other base," he said.
An al-Shabaab spokesman, Sheikh Abdulaziz al-Musab, asserted the group had killed 47 government fighters.
In a statement read out on the extremists' radio Andalus, he said the simultaneous attacks began with suicide car bombs.
There have been fears the al-Qaeda-linked group would be emboldened by Somalia's current political crisis as President Mohamed Abdullahi Mohamed is under pressure to step aside.
Elections meant for February have been delayed.
Mogadishu on Saturday witnessed the opening of a meeting between the federal government leaders, including the president, and the leaders of the five federal member states.
They were expected to discuss the way forward.