In addition, at least 40 people were injured in the attack late Friday night and security forces rescued many others, including children, from the scene at Mogadishu’s popular Hayat Hotel, they said on Saturday.
The attack began with explosions outside the hotel before the gunmen entered the building.
Somali forces were still trying to end the siege of the hotel nearly 24 hours after the attack began.  Gunfire was still being heard on Saturday night as security forces tried to contain the last gunmen believed to be holed up on the top floor of the hotel.
The Islamic extremist group al-Shabaab, which has ties to al-Qaeda, claimed responsibility for the attack, the latest in its frequent attempts to hit places visited by government officials.  The hotel attack is the first major terrorist incident in Mogadishu since Somalia’s new leader, Hassan Sheikh Mohamud, took office in May.
In a post on Twitter, the US Embassy in Somalia said it “strongly condemns” the attack on Hayat.
“We offer our condolences to the families of loved ones killed, wish full recovery to those injured and pledge continued support to #Somalia to hold killers accountable and build when others destroy,” it said.
The identities of the victims were not immediately available, but many are believed to be civilians.
Mohamed Abdirahman, director of Mogadishu’s Madina Hospital, told the AP that 40 people were admitted there with wounds or injuries from the attack.  While nine were sent home after treatment, five are in critical condition in the ICU, he said.
“We were drinking tea near the hotel lobby when we heard the first explosion, followed by gunfire.  I immediately ran to the hotel rooms on the ground floor and locked the door,” witness Abdullahi Hussein said by phone.  “The fighters went straight up and started shooting.  I was inside the room until the security forces arrived and rescued me.”
He said on his way to safety he saw “several bodies lying on the ground outside the hotel reception”.
Al-Shabab remains the deadliest Islamic extremist group in Africa.
The group has seized even more territory in recent years, taking advantage of rifts among Somalia’s security forces as well as disputes between the seat of government in Mogadishu and regional states.  It remains the biggest threat to political stability in the volatile Horn of Africa nation.
Forced out of Mogadishu in 2011, al-Shabab is slowly making a comeback from the rural areas it retreated to, defying the presence of African Union peacekeepers as well as US drone strikes targeting its fighters.
Militants in early May attacked a military base of AU peacekeepers outside Mogadishu, killing several Burundian soldiers.  The attack came just days before a presidential vote that returned Mohamed to power five years after he was voted out.