It was not clear whether Hussein's report of more than 20 killed included the assailants. The armed group Al-Shabab claimed responsibility for the attack at the Beach View Hotel on Mogadishu's Lido beach, an area with many restaurants and other upmarket establishments popular with business people.
Volunteers carried bodies from the scene of the attack early Friday.
"I was intending to go out but suddenly we heard a heavy explosion followed by gunfire. ... I saw a militant fighter shooting indiscriminately on everybody. Then I locked myself inside a room until we were evacuated peacefully by the security forces," said Abdulkadir Mohamed Somow, who had been trapped inside the restaurant.
Blasts and bursts of gunfire could be heard as Somali special forces went from room to room pursuing the Al-Shabab gunmen who were holed up inside the restaurant.
Hussein, the police official, said the security forces rescued many people who had been trapped inside the restaurant's hall, where a party was taking place when the attack started on Thursday.
Witnesses said that gunmen entered the restaurant from the direction of the beach. They shouted "Allahu akbar," the Arabic phrase for "God is great," as they attacked.
"They randomly fired at people sitting near the beach before entering the restaurant," said witness Ahmed Nur, who was strolling along the shoreline when the attack happened.
The armed group Al-Shabab attacked Kenyan peacekeepers in southwestern Somalia last week. The Al-Qaeda-linked group said it had killed about 100 Kenyans and seized weapons and military vehicles. The Kenyan government has given no death toll, but said there were some fatalities.
Al-Shabab wants to topple the Western-backed government in Mogadishu and impose a strict version of Islamic law across Somalia, a nation racked by conflict since the outbreak of civil war in 1991.
Despite being pushed out of Somalia's major cities and towns, Al-Shabab continues to launch deadly guerrilla attacks across the Horn of Africa country. African Union troops, government officials and foreigners are frequently targeted.
Al Jazeera and wire services