Somali government forces said they defeated the militants who attacked the hotel in the capital, after 30-hour siege.
At least 20 people died in the fighting that lasted for 30 hours, although local media reports that the death toll could be higher.
The group that carried out the attack last Friday night used explosives to enter the Hayat Hotel in Mogadishu before taking it completely.
Al-Shabaab claimed responsibility for the attack.
The security forces have now ended the attack and the gunmen are dead. The situation is now under control,” an official told the media on condition of anonymity.
It was difficult for the security forces to enter the hotel for hours, because the forces did not have information on the number of gunmen in different parts of the hotel. The attackers were also said to have detonated bombs in the stairwells of the hotel.
This attack became the longest hotel siege by Al-shabab in Mogadishu.
The government has not yet officially released details of the attack and how it was possible for the attackers to seize the hotel, which is located near Mogadishu airport and the heavily guarded area.