Somalia police rescued 82 people, including several officials and killed two attackers.
Al Shabaab militants attacked a hotel in Somalia's capital near the presidential residence on Tuesday and police said they killed two attackers and rescued dozens of people from inside.
The two attackers were killed outside the hotel as they launched the attack, while two others stormed inside, deputy police commissioner General Zakia Hussen said, adding security forces had rescued 82 people, including several officials.
"We warn people against calling their relatives who they think are in the hotel until the operation is finished," she wrote on Twitter while fighting still raged.
The militant group, which frequently launches bombing and gun raids in Mogadishu in a bid to topple the UN-backed government confirmed it had attacked the Syl hotel, which is popular with officials and lawmakers.
The group had also attacked the hotel in 2016.
One police officer, who only gave his name as Ahmed, said security forces at the hotel had thought the gunmen were police as they approached until they started shooting and hurling grenades. "We exchanged fire at the gate of the hotel," he said.
Al Shabaab's military spokesman Abdiaziz Abu Musab said the group's militants stormed the hotel compound near the presidential palace. "The compound is home to enemy officials," he said.
Osman Abdulle, a witness at a nearby hotel, said he heard gunfire inside the hotel late into the night on Tuesday.
"I could see dozens of people being rescued with ladders placed on the back wall of the hotel. We heard some blasts," he told Reuters. "The whole area is still under siege."
Somalia, in the Horn of Africa, has been mired in conflict and chaos since 1991, when clan-based warlords overthrew a dictator.
Al Shabaab, which once controlled much of the country, was forced out of Mogadishu in 2011 and has since then lost most of its other strongholds. But its fighters regularly attack sites in Somalia and neighbouring Kenya, which has troops in Somalia.