Somali security forces had been trying to clear the attackers’ Hyatt Hotel since Friday evening, when gunmen stormed the building after gunfire and massive explosions struck the area.
Police Major Yasin Haji earlier told CNN that at least 20 people were killed and at least 50 others were injured.
Haji said on Saturday that several fighters were taken hostage from inside the hotel and opened fire on the security forces.
Haji said the attackers had used the hostages “as human shields”, slowing police efforts to end the “terrorist siege”. He said the police had earlier cleared the first and upper floors, while gunmen had occupied the middle two floors.
The upmarket Hyatt Hotel is popular with lawmakers and other government officials.
Major Hassan Dahir, a police officer, told CNN on Friday that two security officers, including Mogadishu’s intelligence chief Muhyiddin Mohamed, were injured in the attack.
On Saturday the US State Department said it “strongly condemns the al-Shabaab attack” on the Hyatt Hotel.
“We express our heartfelt condolences to the families of those who lost their loved ones, wish the injured a full recovery and our appreciation to Somalia’s security forces,” spokesman Ned Price said in a statement on Saturday.
“The United States stands firm in our support of Somali and African Union-led efforts to combat terrorism and create a secure and prosperous future for the Somali people,” he said.
In May, US President Joe Biden decided to redeploy troops to Somalia to support the local government and to counter al-Shabaab. The move reversed former President Donald Trump’s decision to withdraw all US troops from the country.