Somali security forces say they rescued 106 people who were trapped inside a hotel that had been stormed by militants on Friday night (local time).
At least 12 people were killed in the 30-hour ordeal, which officials say is now over. Local media report the death toll could be higher.
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.
Police Commander Abdi Hassan Mohammed Hijra told journalists about the numbers rescued, which he said included women and children, but did not give a death toll.
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.
"The security forces have ended the siege now and the gunmen are dead, we've had no incoming gunfire from the building in the past hour," an unnamed official had earlier told the AFP news agency.
The BBC has not been able to confirm independently whether the attack has ended.
"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.
Relatives of those thought to have been in the hotel when the attack took place are now waiting to find out what happened to them.
"My brother was inside the hotel the last time we heard from him, but his phone is switched off now and we don't know what to expect," businessman Muktar Adan is quoted by AFP as saying.
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.
"So far, we have confirmed 12 people, mostly civilians, died," Mohammed, an intelligence officer who gave only one name, told Reuters news agency on Saturday.
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.
The director of Mogadishu's main trauma hospital told AFP that the facility was treating at least 40 people wounded in the hotel attack and a separate mortar strike on another area of the capital.
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.
- BBC