UN chief Ban Ki-moon expressed outrage at a \"despicable\" Islamist attack on a UN compound in Somalia which left 16 dead but vowed that the organisation would not end its work in the troubled country. Al-Qaeda-linked Shebab insurgents killed nine people as they shot and blasted their way into the UN compound in Mogadishu Wednesday, the most serious attack on the United Nations there in recent years. Three foreigners including two South Africans in the UN compound died, along with a Somali UN worker, two Somali security guards and three civilians in the surrounding streets, officials said. Seven attackers also died in the assault. Ban telephoned Somalia\'s President Hassan Sheikh Mohamud soon after the attack, UN spokesman Martin Nesirky said. \"The secretary general said the United Nations would not be deterred from delivering its mandate,\" said Nesirky, in a statement released from Beijing where Ban is on an official visit. He said Ban was \"deeply concerned and outraged by the despicable attack\". The 15-nation Security Council also expressed outrage -- but stressed its resolve \"that terrorist acts in Somalia will not lessen the council\'s resolve to support Somalia\'s transition to peace and stability\". The insurgents, who boasted about the killings of \"infidels\", used a pickup truck laden with explosives and suicide attackers to blast their way into the fortified base. \"Our commandos attacked the UN compound.... We set off an explosion and entered,\" a senior Shebab official told AFP, saying they had wanted to attack \"the infidel forces\". Somali and African Union troops later moved into the complex -- despite the Islamists battling back with heavy gunfire -- to end the hour-and-a-half siege. \"Somali soldiers along with African Union forces stormed the compound and killed the attackers,\" said Somali police official Abdulahi Osman. Government officials said seven Shebab fighters took part in attack, all of whom either detonated suicide vests or were shot dead. Prime Minister Abdi Farah Shirdon issued a statement condemning the attack as a \"senseless and despicable attack on innocent UN civilians\". He added: \"The UN are our friends and partners, and the UN agencies offer us humanitarian help and support, so I and all Somalis are appalled that they should be the target and victims of such barbaric violence.\" In Washington, National Security Council spokeswoman Caitlin Hayden denounced Shebab\'s \"repugnant terrorist tactics\". The group \"continues to use to stand in the way of efforts to ease the suffering of the Somali people,\" she said. UN sources said those killed included one foreign staff member, one local worker, two South African contractors and two Somali security guards. South Africa\'s state-owned military equipment manufacturer Denel confirmed that two of its South African employees had been killed alongside a Somali employee. The nationality of the other foreigner could not be immediately confirmed. An AFP reporter saw several bloodied bodies carried away on makeshift stretchers. \"Some of the \'white kuffar\' (unbelievers) who tried to engage the mujahedeen in combat inside the offices were killed and thrown out into the compound,\" the Shebab wrote on Twitter. The UN Assistance Mission in Somalia (UNSOM) said the compound housed UN humanitarian agencies. UN staff elsewhere in the city were temporarily pulled back to the secure airport zone, it added. The compound -- including both residential and office areas -- is a short distance from the airport zone, the base of the African Union troops, but is guarded by its own security officers. Security warnings of an attack had been in place for weeks, and UN staff regularly practise sheltering in a secure bunker inside the central Mogadishu compound. Somalia\'s capital has been hit by a series of attacks including suicide and car bombings, mortar attacks and shootings, although in recent weeks the city has been relatively calm. Islamist Shebab militants used to control most of the seaside capital until they abandoned fixed positions in August 2011. Their last major attack was in April, when a nine-man suicide commando unit blasted its way into Mogadishu\'s main court complex, killing 34 people. The attack on the UN compound used similar tactics. The 17,000-strong AU force, fighting alongside Somali government troops, has forced the Shebab from a series of key towns. While riven by infighting and hunted by US drones, Shebab extremists remain powerful in rural areas as well as reportedly having infiltrated the security forces.