At least 13 people are reported to have been killed after militants set off two explosions outside a luxury hotel in Mogadishu and stormed the building.

Heavy gunfire could still be heard inside the Dayah hotel in the Somali capital, the Associated Press news agency reported. Dozens of people - including politicians - were staying at the hotel at the time of the attack.

The Islamist extremist group al-Shabaab claimed the attack through its online radio, Andalus, saying its fighters entered the hotel and an "operation is ongoing".

Major Mohamed Ahmed, a police officer, told Reuters the militants gained entry to the hotel by ramming the gate with a car bomb.

Video emerging on social media showed the second blast occurred some time after the first, with a large number of people already assembled outside the hotel and a police cordon set up.

"At least 13 people, including forces and civilians, died in two blasts at the hotel. A dozen others were injured," the police officer said.

Al-Shabab frequently targets hotels and other public places visited by government officials and foreigners. Al Qaida's east African affiliate is fighting to impose a strict version of Islam in the Horn of Africa nation.

In June, gunmen stormed the Nasa-Hablod hotel, killing at least 14 people. Two weeks before that, gunmen killed 15, including two members of parliament, at the Ambassador hotel.

Despite being ousted from most of its key strongholds, al-Shabab continues to carry out deadly attacks across large parts of south and central Somalia.

Earlier this month, a bomb at a restaurant in Mogadishu killed three people, and a suicide bomber detonated an explosives-laden vehicle at a security checkpoint near the capital's international airport, killing at least three.

That blast occurred a few hundred metres from the main base of the African Union peacekeeping mission.

Al-Shabab's assaults have threatened the nation's attempts to rebuild from decades of chaos. A presidential election, a key step towards recovery, has already been delayed several times because of security and other concerns.