Somalia's president has escaped unhurt from an ambush on his military-escorted motorcade that the armed group al-Shabaab said it carried out.

President Hassan Sheikh Mohamud was approaching the port town of Marka, south of the capital Mogadishu, when al-Shabaab rebels said they fired rocket-propelled grenades at the convoy.

Local police commander Abdikadir Mohamed confirmed Tuesday's attack to the Reuters news agency and said the president arrived safely at Marka, 90 km from the capital. There was no immediate comment from the president's office.

The attack underscores the apparent ease with which al-Shabaab rebels can infiltrate areas under the control of Somali government forces and African peacekeepers and strike at the heart of government.

They have continued to launch guerrilla-style attacks and kidnappings in the city despite being largely pushed out by Somali and African forces two years ago.

"The president narrowly escaped. We are waiting for his return," Sheikh Abdiasis Abu Musab, al-Shabaab's spokesman for military operations, said.

The rebels said they killed several soldiers and destroyed two armoured vehicles from the motorcade that was under escort by African Union and government troops.

Al-Shabaab abandoned Marka and other urban strongholds last year under military pressure from advancing forces loyal to Mogadishu.

Source: Reuters