Somali security forces had been trying to clear the Hayat Hotel of attackers since Friday evening when the gunmen stormed the building following gunfire and large explosions in the area.
At least 20 people have been killed and at least 50 others injured, Police Major Yasin Haji told CNN earlier.
A number of fighters had taken hostages and fired at security forces from inside the hotel, Haji said on Saturday.
Attackers had used the hostages “as human shields” slowing police efforts to end the “terrorist siege,” Haji said. Police had first cleared the first and top floors, while the gunmen held out on the middle two floors, he said.
The upmarket Hayat Hotel is popular with lawmakers and other government officials.
Two security officials, including Mogadishu intelligence chief Muhidin Mohamed, were wounded in the attack, Maj. Hassan Dahir, a police officer, told CNN on Friday.
On Saturday the US State Department said it “strongly condemns the Al-Shabaab attack at the Hayat Hotel”.
“We express our heartfelt condolences to the families who lost loved ones, wish a full recovery to those injured, and commend Somalia’s security forces,” spokesperson Ned Price said in a statement Saturday.
“The United States remains steadfast in our support of Somali and African Union-led efforts to counter terrorism and build a secure and prosperous future for the people of Somalia,” he added.
In May, US President Joe Biden decided to redeploy troops to Somalia in support of the local government and to counter Al-Shabaab. The move reversed a decision by former President Donald Trump to withdraw all US troops from the country.