A suicide bomber wounded two soldiers when he detonated his explosives outside palace gates in Mogadishu [AFP]

A suicide bomber has blown himself up at the gates of the presidential palace in the Somali capital Mogadishu in the latest attack by al Qaeda-linked rebels, police say.

The bomber, armed with an automatic rifle, tried to jump onto an armoured vehicle in a convoy of African Union (AU)peacekeepers driving into the palace grounds on Monday, said Osman Aden, a police spokesman.

When the AU troops fired at the bomber to stop him jumping onto the vehicle, he threw a grenade at them and then detonated his explosive device, Osman said.

The attacker has been identified as a former interior ministry security guard who had defected to al Shabaab, a rebel group linked to al Qaeda, he said.

"Fortunately only two of our soldiers were slightly wounded by shrapnel," he said. "The soldiers were on a small top building at the gate of the palace."

Al Shabaab has been fighting the fragile transitional government of President Sheikh Sharif Ahmed for three years and now controls much of Mogadishu and huge tracts of southern and central Somalia.

The rebels have stepped up their drive to topple the Western-backed administration, and earlier this month suicide bombers killed two African Union peacekeepers and a number of civilians at Mogadishu's airport.

Troubled history

Somalia has been plagued by anarchy since warlords ousted President Mohamed Siad Barre in 1991.  Pirates are active in its coastal waters and have driven up shipping costs in the Gulf of Aden.

The rebels have used suicide bombers to devastating effect over the past two years, killing five government ministers and dozens of AU peacekeeping troops. Al Shabaab was also behind attacks in Uganda in July that killed at least 79 people.

The group has a number of foreign fighters in its ranks and has threatened neighbouring countries that it says support the Somali government.

The peacekeepers in Mogadishu have focused their manpower on shielding the president and guarding the seaport and airport from attacks.

Ahmed, a former opposition leader now seen by the insurgents as a Western puppet, is locked in a power struggle with Prime Minister Omar Abdirashid Sharmarke, who has been under intense pressure to step down in recent months.

The parliament has already voted once to oust Sharmarke, but the prime minister rejected the vote in May as unconstitutional and refused to resign.

Source: Agencies