At least three Somali civilians died in the al-Shabaab assault on a UN compound in Mogadishu, medics said on Thursday, bringing the confirmed death toll to 18.

At least four foreigners — including two South African contractors — were killed in the attack on Wednesday, along with four Somali nationals employed at the UN.

The attack was a setback for Somalia, which has been using a period of relative calm in the past nine months to attract international aid organisations back to the war-torn country.

Seven al-Shabaab fighters were killed as African Union and Somali government troops retook the UN building in an hour-long fire fight.

Three civilians died in the heavy exchanges of gunfire, and 18 others were being treated in hospital for their injuries, according to medical sources.

The death toll could rise further.

The attack on the compound was condemned by the UN Security Council and the Somali Government.

Al-Shabaab said the attack was meant to “dislodge” the UN from Somalia. The group called the UN a “merchant of death and a satanic force of evil” that was a puppet of the United States.

Somali President Hassan Sheikh Mohamud admitted that the urban guerrilla warfare was not likely to abate soon and “we will sadly be subject to this sort of mindless terrorism for some time.” The Islamist rebels have been on the back foot since 2011, but still control vast swathes of territory in southern and central Somalia.

More In: World | International | News