Gunmen used two car bombs to blast their way into the Sahafi hotel compound before storming the building, police said.

Victims included at least one MP and the general who led the 2011 offensive that drove al-Shabab out of Mogadishu.

African Union troops and government forces say they have regained control of the hotel after a fierce gun battle.

The hotel is popular with Somalia's members of parliament.

A website associated with al-Shabab said it was responsible for the attack, which it said was carried out early in the morning to avoid civilian casualties.

This is a clear change in strategy, says BBC World Service Africa editor Mary Harper. Until now, attacks in Mogadishu have been carried out during the day and evening, killing civilians who happen to be in the targeted area.

The owner of the hotel and Gen Abdikarim Dhagabadan, who commanded the operation against al-Shabab in 2011, were among the victims.

The attack comes a day after deadly clashes between jihadist fighters and African Union (AU) troops in the Bakool region near the border with Ethiopia.

The AU is helping the government battle al-Shabab.

Security in Somalia has improved, but the al-Qaeda linked group still attacks Mogadishu regularly.

The militants have also targeted neighbouring countries, killing almost 150 people in an assault on Garissa University College in Kenya in April.

Image copyrightEPAImage caption
Gunmen used a vehicle packed with explosives to blast their way into the hotel

Image copyrightAFPImage caption
The al-Shabab militant group has carried out regular attacks in Somalia