Somali security forces have said they rescued 106 people who were trapped inside a hotel that had been stormed by militants on Friday night.
Twenty-one people are confirmed to have died in the 30-hour ordeal, the health ministry said. The fight to retake the hotel ended overnight, officials said.
The assailants used explosives to gain entry to Mogadishu’s Hayat Hotel before violently taking control.
Islamist militant group al-Shabab has taken responsibility for the attack.
“I would like to inform all Somalis that the operation at the hotel was concluded at midnight,” police Commander Abdi Hassan Mohammed Hijra told journalists in a briefing that took place close to the site of the attack.
“It is shocking that innocent people lost their lives here… The security forces were engaged in rescuing the people one by one and in groups.”
The death toll could rise as there is the possibility that family members collected the bodies of relatives before an official count was made, Health Minister Ali Haji Adan said. He added that 117 people were injured, with 15 of them being in a critical condition.
The hotel has been largely destroyed following intense fighting between the militants and security forces throughout Friday night and Saturday, with videos showing explosions and smoke billowing from the building’s rooftop.
“It has been terrible, really terrifying living next door to the gunfire, the explosions. It was one of the most horrible things I have ever seen in Mogadishu,” Abdisalam Guled, a former deputy director of Somalia’s national intelligence agency, told the BBC.
A police officer told Reuters that two car bombs had been used to gain access to the hotel on Friday evening – targeting its front barrier and gate.
After the initial attack, a website affiliated to al-Shabab said a group of militants were “carrying out random shootings” after having “forcibly entered” the hotel – described as a popular location for employees of the federal government to meet.
Security forces struggled to gain access to the upper floors of the hotel for hours because the gunmen, who were holding an unknown number of people hostage, had reportedly bombed out the stairs needed for access.
An affiliate of al-Qaeda, al-Shabab has engaged in a long-running conflict with the federal government.
The group controls much of southern and central Somalia, but has been able to extend its influence into areas controlled by the government based in Mogadishu.
In recent weeks, fighters affiliated with the group have also attacked targets along the Somalia-Ethiopia border, which has raised concerns about a possible new strategy by al-Shabab.
The attack on Friday marks the first in the capital by the group since Somalia’s new President, Hassan Sheikh Mohamud, was elected in May.
Hotels and restaurants have been frequent targets, but Mogadishu saw its deadliest attack in October 2017, when more than 500 people were killed when a truck filled with explosives was detonated at one of the city’s busiest intersections.
No group said it was behind that attack, although correspondents say all indications are that al-Shabab was responsible.