Nine people died after al Qaeda-linked Islamist insurgents stormed a hotel in the Somali capital Mogadishu, battling security forces until the early hours of Monday, a police spokesman said.
A suicide car bombing on Sunday evening was followed by a shootout between al Shabaab militants and security forces at the Hotel Afrik.
"The operation is over now. Nine people including four attackers died and over 10 civilians were injured," Sadik Ali, told reporters from the scene and via Facebook.
The attack on a hotel in the heart of the heavily fortified city comes as Somali politicians wrangle acrimoniously over delayed elections and follows the withdrawal of around 700 US military personnel last month.
The US troops were largely supporting Somali special forces known as Danaab who are skilled at complex operations against high level al Shabaab targets.
They also enjoyed considerable support from the Americans, including air support and medical evacuations, and some Somali politicians have raised fears the pullout ordered by US President Donald Trump could weaken the fight against al Shabab.
The insurgency has battled since 2008 to overthrow Somalia's internationally-backed central government and establish its rule, based on its own harsh interpretation of Islamic law.
It carries out regular gun and bomb attacks in Mogadishu and elsewhere in Somalia.
It has also vowed to disrupt national elections, which were scheduled to begin in December but have been delayed after the opposition accused the president of packing the electoral board with his allies. Newly appointed legislators were meant to pick a president on Feb. 8, but even the elections for lawmakers have yet to be held.
Times of political turmoil have also traditionally provided a boost to the insurgency, as security chiefs may be ordered to concentrate on political rivals rather than al Shabaab.
Prime Minister Mohamed Hussein Roble said in a statement that former military general Mohamed Nur Galal was among those killed in Monday's attack.
"I condemn the barbaric attack," he said. "General Mohamed Nur Galal will be remembered for his over 50 year role in defending the country."