The Jazeera Palace is a heavily guarded hotel.

AFP/Mogadishu 

Somalia's al Shabaab insurgents killed at least six people on Sunday when they detonated a huge car bomb at a heavily guarded hotel in the capital Mogadishu housing diplomatic missions, officials and witnesses said.

The attack, the latest in a string of bomb blasts and killings in Somalia, came as US President Barack Obama left neighbouring Kenya and headed to Ethiopia, both key nations contributing troops to the African Union force battling the Al-Qaeda-affiliated group.

In a statement quoted by jihadist websites, the Shabaab said they attacked the Jazeera Palace hotel, which is also home to the diplomatic missions of China, Qatar and the United Arab Emirates and is popular among Somali government officials and foreign visitors.

"We have seen around six people killed, most of them hotel security guards," said government security officer Mohamed Jama, adding that the toll might rise.

Local resident Abdihakim Ainte, a political analyst, was nearby when the bomb exploded and described a "huge blast" that smashed his window.

Hotel 'torn apart'

He said the hotel had been "torn apart" by the blast, and photographs shared on social media showed the side of the six-storey hotel demolished by the explosion. The enormous blast also sent a thick plume of smoke high into the air.

Mogadishu resident Mohamed Moalim was at the hotel when the bomb exploded.

"It was a truck loaded with explosives - and the biggest ever (explosion) around this area," he said.

The AU force in Somalia (AMISOM) said it was helping to evacuate the wounded.

The Jazeera, close to the fortified international airport, houses the UN, Western diplomatic missions and AMISOM. The hotel has been the target of Shabaab attacks in the past, including in 2012 when suicide bombers stormed the hotel while President Hassan Sheikh Mohamud was inside.

The Shabaab are fighting to overthrow Somalia's Western-backed government which is propped up and protected by the 22,000-strong AMISOM force.

Attack on MP

On Saturday Shabaab gunmen in Mogadishu killed MP Abdulahi Hussein Mohamud, spraying his vehicle with gunfire as he travelled through a southern district of the city, killing him, his two guards and the driver.

The Shabaab said in a statement that its "mujahedeen fighters targeted and killed a member of the parliament and his guards", adding that it "will continue targeting" lawmakers.

The US president, speaking in Nairobi on Saturday, said that while the Shabaab had been "weakened", the overall security threat posed by the group remained.

"We have been able to decrease their effective control within Somalia and have weakened those networks operating here in East Africa. That doesn't mean the problem is solved," Obama said.

"We can degrade significantly the capacity of the terrorist organisations, but they can still do damage," he added.