Analysis

The UN compound in Mogadishu is just a few hundred metres from the airport where thousands of African Union troops are based.

It is in the heart of one of the most sensitive and theoretically well-guarded areas of the city.

But following the audacious attack the gateway into the compound is now a wreck of twisted metal and rubble.

For more than a year now the Somali government - and its Western and African backers - have been lauding improved security in Somalia.

At a diplomatic conference in London in February, hosted by the British Prime Minister David Cameron, there was optimistic talk about the new government which was for the first time elected by a parliament.

It is true that the militant Islamist al-Shabab group has been forced, by African Union troops, to leave most of their military positions in the city.

But this attack shows that opponents of the government still have the capacity to hit a high-profile target which should be one of the best protected locations in the country.

Officials say pro-government forces have now secured the compound.

The UN has only recently expanded its operations in Mogadishu after years when its Somalia mission was based in neighbouring Kenya because of security fears.

This is the first time the UN offices have been attacked since it relaunched its mission in Somalia.

The UN Development Programme office is next to the heavily fortified airport in southern Mogadishu.

"A suicide bomber blew himself up at the gate of the UNDP and then several armed fighters went in and opened fire," a senior police official told the Reuters news agency.

Interior Minister Abdikarim Hussein Guled said at least 15 people had been killed - four foreign security workers, four local guards and seven militants.

Two of the dead worked for South African state weapons firm Denel, the company says.

The UK Foreign and Commonwealth Office says it is looking into reports that three British nationals are among the dead.

The al-Shabab Twitter feed says it killed 16 UN workers, including three Britons, two Kenyans and a South African during the attack.

A police official told AFP that three civilians also died after being caught in crossfire.

The cameraman, who asked not to be named for security reasons, told the BBC Somali Service that he had personally helped three people to a military ambulance.

Local residents have fled and some buildings were seriously damaged after the vehicle exploded, he said.

He said a number of security experts had joined the African Union (Amisom) and Somali soldiers in tackling the militants.

Just after 10:15 GMT al-Shabab said on its Twitter feed: "We've just contacted the Mujahideen inside the #UNDP and they are still fighting some western mercenaries inside the compound."

Later it said it had killed some foreigners in the raid.

"The situation is under control now... Somali soldiers along with African Union forces stormed the compound and killed the attackers," Somali police official Abdulahi Osman told the AFP news agency.

Amisom described the attacked as "cowardly" and Somali Prime Minister Abdi Farah Shirdon Saaid praised the speed of the security forces' response.

"Somali and Amisom security forces responded immediately to the situation after the initial explosion and have brought the situation under control. Sadly we must wait to hear the full details and confirmation of any casualties," he said in a statement.

"All our thoughts and prayers are with our UN colleagues today. But al-Shabab will not derail the peace process. They will not stop our recovery. Violence will not win."

Earlier a UN official told the Associated Press news agency that during the sustained firing all staff were "moved to the bunkers where it's safe".

Andrew, an aid agency worker staying at a nearby hotel, witnessed some of the fighting.

"When I heard the explosions I went up onto the roof of the Jazeera Hotel," he told the BBC.

"There were six mini-explosions. We saw UN troops on the roof of their compound shooting down at the attackers. An RPG-7 hit the hotel, it hit the side wall on the fifth floor."

Al-Shabab, which had been in control of parts of Mogadishu for more than two years, withdrew in August 2011 under pressure from pro-government forces, but continues to launch occasional suicide attacks in the city.

It has also been pushed out of other cities, but still remains in control of smaller towns and large swathes of the countryside in central and southern Somalia.

The improving security situation has prompted the return of Somalis from the diaspora and allowed UN agencies and foreign embassies to return to the country.

Some 18,000 AU troops are in the country supporting the government of President Hassan Sheikh Mohamud who was elected by MPs last September.

His administration is the first one in more than two decades to be recognised by the US and the International Monetary Fund (IMF).

This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.