President Mohamud
Somalia's newly elected President Mohamud (left) shakes hands with Kenya's foreign minister Ongeri in Mogadishu (Reuters)

Somalia's newly elected president escaped a suicide bomb attack that killed five at the hotel where he was staying in the capital, Mogadishu.

Two explosions were reported at the gates of the Jazeera Hotel near the airport where President Hassan Sheikh Mohamud was holding a conference with Kenya's foreign affairs minister Sam Ongeri.

Three soldiers were killed in the blasts. Mohamud and Ongeri escaped unharmed.

"There has been a blast around the hotel where the president was. The president is safe. All the people who were inside the hotel are safe," Col Ali Houmed, a spokesman for the African Union force in Somalia, said.

Two suicide bombers from the radical Islamist group al-Shabab parked a car next to the hotel and walked towards the building entrance, said witnesses.

At the gates, one blew himself up and the other ran inside the hotel opening fire on security forces.

It is not clear if the second attacker was shot dead or died blowing himself up.

Mohamud was elected just two days earlier in the first presidential vote in Somalia in decades.

Al-Shabab opposed the election saying it had been organised by "enemies of Somalia" and manipulated by the West. Mohamud was branded as a traitor.

"We are responsible for the attack against the so-called president and the delegation," al-Shabab spokesman Ali Mohamud Rage said.

A Somali government soldier patrols the scene of an explosion in the capital of Mogadishu (Reuters)
Bomb Somalia
A military truck drives past the body of a dead soldier at the scene of the explosion in capital Mogadishu (Reuters)