The attack took place in the strategic Somali town of Afgoye. (Representative image) Photograph: (Getty)
The attackers also suffered casualties
Fighters from the Al-Qaeda-linked Shabaab group launched a major attack on a strategic town near Mogadishu on Tuesday, killing at least 10 people, including civilians, before retreating.
Witnesses and officials reported heavy clashes between Shabaab militants and Somali troops in Afgoye, which lies just 30 kilometres (18 miles) northwest of the capital Mogadishu.
The main target of the assault was a police post attacked with a car packed with explosives, and Somali army posts. Heavy exchanges of fire were also heard around the town.
The Shabaab fighters pulled out before troops from the African Union's peacekeeping mission in Somalia, AMISOM, arrived.
"The terrorists have retreated back from the town and the situation is back to normal, Somali government forces are now in full control," local police official Abdukadir Ahmed said by phone.
"We don’t have the exact number of casualties so far but we have seen the dead bodies of more than 10 people, including civilians, who were killed in the attack."
He said the attackers also suffered casualties.
AMISOM confirmed on Twitter that a car bomb had been used to target a police post but said Somali forces had held their position, waiting for reinforcements.
Witnesses said the Shabaab fighters left town and dead bodies were strewn in some roads.
"Shabaab fighters left the police station and other locations they have taken this afternoon, there are dead bodies and I saw 11 of them at our neighbourhood. Somali and AMISOM soldiers are now in some parts of the town," Abdirisak Isgowe, a resident, said.
Another resident, Fadumo Wariri, said most of those killed perished in the blast, and most were soldiers.
A statement from Shabaab said they had killed 35 government soldiers and seized a sizeable quantity of military equipment from the posts it attacked.
It was not immediately clear whether the main aim of the Shabaab operation was to seize equipment or to show they were capable of launching attacks at will, even in daylight.
The attack on Afgoye, which lies at a strategic crossroads of routes heading north, west and south into Somalia, shows the country's continuing fragility.
On Saturday the UN humanitarian agency said a week of violent clashes in northern Somalia had left 11 people dead and driven more than 50,000 people to flee.
In just a few weeks Somalia is due to hold elections that it is hoped will bring a measure of stability to the conflict-plagued nation.
The Shabaab has fought to overthrow the internationally-backed government in Mogadishu since 2007, losing control of the capital in 2011 before losing other bastions such as Afgoye.