Suspected al-shabaab members and their weapons are paraded
Suspected al-shabaab members and their weapons are paraded (Reuters)

Somalian and African Union forces have regained control of a UN compound in the Somali capital of Mogadishu after it was attacked by rebels linked to al-Qaida.

"The situation is under control now. Soldiers stormed the compound and killed the attackers," said police official Abdulahi Osman.

At least three civilians were killed outside the compound. No UN casualties were reported.

Militants with the al-Shebaab group attacked the compound in the first major assault on the organisation in years.

According to witnesses, an was heard in the building, which is home to several UN humanitarian agencies. The blast was followed by the sound of heavy gunfire.

Reportedly, the attack started after a suicide bomber blew himself up at the gates of the complex but that has not been confirmed.

A plume of thick black smoke billowed into the sky above the city, according to Al Jazeera.

"Our commandos have attacked the UN compound. We set off an explosion and have entered the compound, where we are fighting with the infidel forces," a senior al-Shebaab official said at the time.

The compound includes both residential and office areas. UN staff were believed to be sheltering in a bunker at the compound.

Al-Shabaab fighters used to control most of the capital until they abandoned positions in August 2011