The siege of the Afrik hotel ended after a gun battle that lasted for more than eight hours, and all four rebel attackers were also killed, Somali police spokesman Sadiq Adan Ali said.
The rebels exploded hand grenades and rocket-propelled grenades in their attempt to repulse the police forces who were closing in on them, he said.
In addition to those killed, 15 people were injured and have been hospitalized, health authorities said.
Al-Shabab claimed responsibility for the attack through their Andalus radio and Somalimemo website.
Among the dead are General Mohamed Nur Galal, a well-known retired army veteran who lived in the hotel.
Another general and more than 100 civilians were rescued from the hotel, which is near the strategic K-4 junction on the road to the capital city’s international airport, said Ali.
The road leading to the airport has been reopened Monday morning and forces are cleaning of the destruction caused by the explosion of a vehicle at the entrance to the hotel which started the attack Sunday.
Somalia’s President Mohamed Abdullahi Mohamed and the country’s prime minister condemned the attack and sent their condolences to the families of the deceased.