At least four people were killed on Thursday when fighters from the Al Shabaab extremist group raided a town near Somalia's capital Mogadishu, police said.
The attack came with the troubled country in the grip of an escalating political crisis that pits the president against the prime minister.
The attackers, armed with machine guns, raided the town of Balcad, about 30 kilometres north of Mogadishu, police and witnesses said.
"The terrorists attacked Balcad early this morning, targeting government security checkpoints," police officer Abdullahi Mohamed told AFP.
"The situation [has] returned to normal now and the government forces are in full control."
Witnesses said the Al Shabaab fighters managed to enter some parts of the town, which is on a road linking Mogadishu to the rest of the country, before they were repelled.
President Mohamed Abdullahi Mohamed and Prime Minister Mohamed Hussein Roble are locked in a festering feud over long-delayed elections in the Horn of Africa nation.
The president, better known as Farmaajo, this week announced that he was suspending the premier, who in turn accused him of an "attempted coup".
Relations between the pair have long been frosty, with the latest developments raising fresh fears among international partners that the government could be distracted from its fight to quash the extremist insurgency.
Al Shabaab has been waging a violent campaign against the country's fragile government since 2007 but was driven out of Mogadishu in 2011 after an offensive by an African Union force.
But the Al Qaeda-linked insurgents retain control of vast rural areas of Somalia, from which they frequently launch deadly attacks in the capital and elsewhere against civilian, military and government targets.
The extremists last month claimed a deadly car bombing in the capital that killed eight people and injured a number of students.
The militants also claimed two attacks in September that together killed 17 people.