Somali security forces have brought to an end a bomb and gun attack by militants on a central Mogadishu hotel that killed at least 16 people and wounded 55, authorities said.

Islamist militant group al Shabaab, affiliated with al Qaeda, claimed responsibility for the attack which began yesterday on the Hotel Ambassador.

Two Somali politicians who both held dual British citizenship were among the dead in the attack which ended with police shooting the assailants.

"So far we have confirmed 16 people, mostly civilians, died and 55 others were injured," a senior police officer said.

A Reuters witness saw the last fighter shot dead, his body falling to the ground from the building's fifth floor. Eight dead people lay in front of the hotel.

Al Shabaab was pushed out of Mogadishu by the African Union peacekeeping force AMISOM in 2011.

But it has remained a potent threat in Somalia, launching frequent attacks aimed at overthrowing the Western-backed government.

The group has also been behind deadly attacks in Kenya and Uganda. Both contribute troops to an African Union peacekeeping force in Somalia.

Earlier, witnesses said sporadic gunfire had continued at the hotel early this morning, with police still combing the building's five floors for militants and to rescue those still trapped.

The building was extensively damaged during the attack and government forces had blocked off all the main roads near the scene.