Somali security forces have ended a night-long siege by at a Mogadishu hotel by five extremists who stormed the building after a suicide car bomber detonated an explosives-laden vehicle at the entrance gate, killing 23 people.
Troops regained control of the Nasa-Hablod hotel on Sunday morning, having killed three attackers and captured two alive, said Captain Mohamed Hussein.
Al-Shabab, Africa's deadliest Islamic extremist group, quickly claimed responsibility for Saturday's outrage, two weeks after more than 350 people were killed by a massive truck bomb in a busy Mogadishu street in Somalia's worst attack.
The assault started on Saturday afternoon when a suicide truck bomb exploded outside the popular hotel in the capital.
The blast twisted vehicles and caused massive damage to nearby buildings which were left with only their walls standing.
The attackers invaded the hotel and gunfire continued as security forces fought them inside the building. Two more blasts were heard, one when an attacker detonated a suicide vest.
Minister of electricity and water Salim Aliyow Ibrow was rescued from the hotel as heavy gunfire continued in the shoot-out. Some extremists hurled grenades and cut off the building's electricity as night fell.
Included in the dead were a mother and three children, including a baby, all shot in the head, Capt Hussein said. Other victims included a senior Somali police colonel, a former MP and a former government minister.
The bomber had pretended his truck had broken down outside the gate, said police colonel Mohamed Abdullahi, stopping outside the heavily-fortified hotel and pretending to repair the vehicle before detonating it, he said.
Al-Shabab often targets high-profile areas of Mogadishu. Although it quickly said it carried out Saturday's attack, it has not commented on the bombing two weeks ago.
Experts have said the death toll in the earlier bombing was so high that the group hesitated to alienate Somali citizens.
Somalia's president Mohamed Abdullahi Mohamed said the new attack was meant to instil fear in Somalis who united after the October 14 bombing, marching in the thousands through Mogadishu in defiance of al-Shabab.
Since that blast, the president has visited regional countries to seek more support for the fight against al-Shabab, vowing a "state of war".
He also faces the challenge of pulling together regional powers inside his long-fractured country, where the government is only now trying to assert itself beyond Mogadishu and other major cities.
The US military has also stepped up military efforts against al-Shabab this year in Somalia, carrying out nearly 20 drone strikes, as the global war on extremism moves deeper into the African continent.
A 22,000-strong multinational African Union force in Somalia is expected to withdraw its forces and hand over the country's security to the Somali military by the end of 2020.
US military officials and others in recent months have expressed concern that Somali forces are not yet ready to take over.
The two attacks this month have shaken public confidence in the ability of Somali army to take over from the African Union forces. Many in the capital accuse the government of not doing enough to protect them.
"We are dying in hundreds now," said Ahmednur Hashi, a Mogadishu resident. "Who is going to protect us?"