Among those killed at the popular hotel was the well-known retired General Mohamed Nur Galal, said Somalia’s Information Ministry.
Police officers gave varying death tolls, ranging from at least nine to 17, with four attackers included among those killed. Up to 30 people were injured.
“The operation is over now,” said police spokesman Sadik Ali.
“I have never witnessed such a level of devastation,” said bystander Ali Ato, who said he went to the hotel to recover the body of a colleague.
The attack began Sunday evening with a suicide car bombing at the hotel’s entrance followed by a shootout between al-Shabab militants and security forces.
The hotel is located at a busy junction near the Somali capital’s airport.
Somali Prime Minister Hussein Roble condemned “the barbaric attack” and acknowledged the general for his “50 year role in defending the country.”
Since 2008, al-Shabab has sought to overthrow Somalia’s internationally backed central government. Stationed in Somalia is an African Union peacekeeping force, which since 2017 has clawed back control of areas from the extremist group.
Somalia’s federal government and regional states have, however, quarrelled over power and resources.
On February 8, Somalia is scheduled to hold indirect parliamentary and presidential elections, but two regional states, Jubbaland and Puntland, have objected to how delegates were selected and electoral management bodies appointed.
Associated Press quoted United Nations special representative James Swan last week as warning officeholders that their use of a resolution to stay on would bring “an unpredictable political situation in a country where we certainly don’t need any more of that.”
A future Somali government faces a number of urgent challenges, including locust swarms that have devastated crops, the COVID-19 pandemic and hundreds of thousands of Somalis still displaced by drought exacerbated by climate change.
Last September, Somali President Mohamed Abdullah Mohamed appointed Roble as prime minister, who in October then reshuffled his cabinet. Roble studied civil engineering and previously worked for the UN’s International Labor Organization.
Previous premier Hassan Ali Khaire lost his post in July amid a power struggle over whether to delay the national elections.