At least 10 soldiers killed after a coordinated assault on an army base southwest of Somalia's capital Mogadishu.

Fighters from Somalia's armed group al-Shabab have attacked an army base southwest of the capital, Mogadishu, killing at least 10 soldiers, the group and a military officer told the Reuters news agency.

The attackers exploded a car packed with explosives before storming the Lanta Buro base in Lower Shabelle region, some 50km outside Mogadishu, on Monday morning.

"Heavy exchange of gunfire continued for hours," Major Ahmed Farah told Reuters from the nearby town of Afgooye. At least 12 al-Shabab fighters were killed, he added.

Residents said they heard heavy gunfire and an explosion before the fighters stormed the base.