Al Shabab extremists attacked a hotel used by government officials in Somalia's capital Mogadishu on Sunday.
They stormed the Villa Rose Hotel, which is close to the presidential palace, with explosives and guns. It was not immediately clear how many attackers were there.
Al Qaeda-linked Al Shabab, which controls large parts of the country, claimed responsibility for the attack, saying it was aiming for the palace.
"We were shaken by a huge blast, followed by heavy exchange of gunfire," said Ahmed Abdullahi, who lives close to the scene. "We are just indoors and listening to gunfire."
Security forces were responding to the attack by Al Shabab on a hotel in the capital's Bondhere district, state broadcaster SNTV said on Twitter.
"The forces rescued government officials and members of the public who were trapped in the building," it said.
Some government officials at the Villa Rose were rescued after escaping through windows, said police officer Mohammed Abdi.
The Minister of State for the Environment, Adam Aw Hirsi, wrote on Twitter that he was safe after a "terrorist explosion targeted at my residence" at the hotel, where many government officials stay.
President Hassan Sheikh Mohamud, who was elected this year, has been carrying out a military offensive against Al Shabab.
Al Shabab has staged attacks in Mogadishu since it was driven out of the capital in 2013.
In August, more than 20 people were killed when Al Shabab attacked the Hayat Hotel in the capital.
The group has recently resorted to bombings after losing ground to the government offensive backed by local clans in several regions.
A double car bombing in Mogadishu on October 29 killed more than 120 people and injured about 300 others.