Somali soldiers stand next to the site

Somalia's Shebab insurgents killed at least six people 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 suicide 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 Shebab 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.

The Shebab said the suicide bomber had attacked the hotel "in retaliation for the killing of dozens of innocent civilians" they claimed had died during attacks this week by Ethiopian forces against Shebab bases in southern Somalia.

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

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.

Journalist Mohamed Abdikarim, who worked for Universal TV, was among those killed, the National Union of Somali Journalists said in a message of condolence to his family.

The Jazeera is close to the fortified international airport, which houses the United Nations, Western diplomatic missions and AMISOM.

The hotel has been the target of Shebab attacks in the past, including in 2012 when suicide bombers stormed the hotel while President Hassan Sheikh Mohamud was inside.

Mohamud on Sunday condemned the "heinous terrorist attack" and said the Shebab attacked a civilian target because they were losing territory to government and AU troops.

- Islamists down but not out -

The AU force in Somalia (AMISOM), which helped to evacuate the wounded and rescue those who had been staying in the hotel, said it "demonstrates the demonic agenda" of the Shebab.

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

On Saturday Shebab 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 Shebab 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 Shebab 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.

Somali government and AMISOM troops last week launched a fresh offensive it said was aimed at flushing the insurgents out of rural areas in southern Somalia, in an operation involving Ethiopian and Kenyan forces.

Deployed to Somalia since 2007, AMISOM has helped push back Shebab across much of the country's south, retaking towns and territory the group had held for years.

US drone strikes have also taken their toll on Shebab, killing senior commanders, including the group's leader Ahmed Godane in September last year.