"The Somali forces and AMISOM peacekeepers secured control of Merka again and now the situation has returned to normal," a Somali military official, Abdirisak Mohamed, told AFP by telephone from Mogadishu.
"There was brief exchange of gunfire, but the (Shebab) militants have fled."
He said "several" Shebab fighters and one Somali soldier were killed in the clashes, and "the security forces are now conducting clearing operations inside town."
"Four people died in our neighbourhood and two others were wounded, I can see AMISOM and Somali troops returned to the city now and they are conducting security operations", Muhidin Osman said.
More From This Section
Another resident, Shamso Moalim, said "Shebab fighters pulled out of the town after putting up slight resistance, the Somali forces and AMISOM are back".
"There are civilian casualties but I don't know the number", she added.
The Al Qaeda-linked Shebab said on its website that one of its leaders, Sheikh Mohamed Abu-Abdallah, addressed hundreds of people gathered at the regional government headquarters in Merka after the seizure yesterday.
"The enemy has lost and running away, they are fleeing from the Islamic regions," it quoted him as saying.
Residents said earlier today that the Shebab had begun imposing Sharia law on the city.
The Shebab are fighting to overthrow the internationally-backed government in Mogadishu, which is protected by 22,000 AU troops.
The group has lost ground since being routed from Mogadishu in 2011, but continues to stage regular shooting and suicide attacks, and in recent months has staged a series of brazen raids on AU bases.
Last month they stormed a Kenyan army base at El-Adde in southwest Somalia, in the latest incident of an AMISOM base being overrun, before retreating.