At least ten people have been killed in an attack on a hotel popular with government officials in the Somali capital, Mogadishu.

The African Union mission to Somalia, AMISOM, confirmed to Al Jazeera that there had been an explosion followed by gunfire at the Makka al-Mukarama hotel on Friday.

An AMISOM spokesman said al-Shabab fighters got out of a car that then exploded. The armed men then entered the hotel and gunfire was heard. The fighters took hostages, the spokesman added.

Al-Shabab claimed responsibility for the attack. The group attacked the same hotel, popular with government officials and foreigners, in November 2013.

At least four gunmen trapped an unknown number of people inside the building, security official Captain Mohamed Hussein told the Associated Press news agency.

Some people jumped out of the hotel's windows, and one who made it safely outside said the attackers were killing anyone they could find.

Somali special forces, facing bullets from gunmen holed up inside dark corners of the hotel, aimed their weapons at the hotel's windows.

Somalia's ambassador to Switzerland, Yusuf Mohamed Baribari, was also killed in the attack, medical sources told Al Jazeera.