Somali government troops have shot dead three Islamist militants holed up in a building in central Mogadishu, ending a day-long bomb and gun attack that killed at least 29 civilians.
Islamist al Shabaab fighters launched the assault by setting off a suicide car bomb outside the Maka Al-Mukarama hotel on Thursday evening, destroying other structures, igniting a huge fire and leaving people wounded in the rubble.
The militants - who are fighting to overthrow the Western-backed government - fled to a neighbouring building and opened fire on special forces and other soldiers throughout Friday.
"The operation is over and the building is now controlled by the security forces. The three militants were shot dead, their bodies are inside the building," police officer Captain Osman Mohamed said late on Friday afternoon.
It was the longest that the militants had held a position in Mogadishu since Somali troops backed by African Union peacekeepers forced them out of the city in 2011.
The attack on the hotel came the same day that US forces said they carried out an air strike that killed 26 militants in the Hiran area, north of the capital, part of an escalation of Washington's fight against the al-Qaeda-linked group.
Somalia's government had earlier said the gunmen took hostages, but there were no immediate details on their fate.
"There are no civilian casualties in this building. But there may be dead civilians under the collapsed Hilco UK restaurant which is also nearby," Captain Mohamed said.
Health officials said it was too early to estimate the full impact of the attack. "The death toll may rise and rise," said Abdikadir Admen, the director of the privately-run Amain ambulance service.
There was no immediate confirmation of the end of the battle from al Shabaab which earlier in the afternoon said it still controlled the hotel and had repulsed three government raids on the building.
Soldiers manned roadblocks around the site during the fighting and fired into the air to keep back relatives who shouted out the names of missing loved ones.
"I have been running to and fro from the blast scene to hospitals since yesterday (Thursday) evening in search of my husband and brother ... I have just seen them in hospital. They are in a critical condition," mother-of-three Hallam Omar told Reuters.