MOGADISHU (Reuters) - Al Shabaab fighters killed at least 15 soldiers in an attack on a military base near Somalia’s capital, Mogadishu, the militant group and Somali officials said on Friday.

The militants used guns and car bombs to take control of the base and a nearby town, Barire, 50 km (30 miles) southwest of Mogadishu, in an early-morning attack.

The fighters also took 11 pickup trucks mounted with machine guns, known as “technicals”, said Abdiasis Abu Musab, al Shabaab’s military operation spokesman.

“The other soldiers ran helter-skelter into the woods. We now control the base and the village,” he said.

A Somali military officer put the number of dead at 15; al Shabaab said 21 were killed. The government and al Shabaab often give differing accounts of death tolls.

“There was a battalion of soldiers but it was a fierce fighting; twin suicide car bombs and hand-to-hand fighting,” Captain Osman Ali told Reuters.

“The attacked soldiers were Somali military and the special forces trained by the U.S. called Danab. There were neither AMISOM nor other foreigners there,” Ali added, referring to African Union peacekeeping troops. Reinforcements were being sent, he said.

Al Shabaab aims to topple the government in Mogadishu and impose its own strict interpretation of Islam. Somalia has been at war since 1991, when clan-based warlords overthrew dictator Siad Barre and then turned on each other.

The al Qaeda-linked group was driven out of the capital in 2011, but it still carries out frequent attacks on security and government targets and African Union peacekeeping troops. Civilians sometimes get caught in the crossfire.

Ali Nur, the deputy governor of Lower Shabelle region where Barire is situated, confirmed the fighting. So did local residents.

“First we heard two huge blasts at the base and then heavy exchange of gunfire followed. Now it looks like the fighting died down,” Ali Farah told Reuters from Barire village.

Two weeks ago, al Shabaab attacked an army base at a town near the border with Kenya. Three weeks ago they struck another in the southern port city of Kismayu, killing a total of at least 43 people in the two attacks.