The Defence Forces has confirmed that four Irish soldiers are unharmed following a terrorist attack on a United Nations compound in Somalia.

Somali Islamist militant group al-Shabaab said its fighters were behind an attack on the building in Mogadishu.

It said the battle between their gunmen and security forces continued more than an hour after an initial blast.

Four Defence Forces personnel are stationed at a European Union building at Mogadishu airport near the location of the attack.

However, a spokesperson has confirmed the EUTM base was not affected by the incident.

The Somali government said 15 people had died in the attack, including four foreign soldiers, although it did not specify their nationalities.

The compound that was attacked lies just across the street from the secure airport complex.

A UN official said the staff inside the building were moved to bunkers.

Senior UN official in Somalia Nicholas Kay works out of the building, but was was not inside the compound when it was attacked.

Troops from the African Union force AMISOM said they had secured the compound after the attack.

The facility is used by agencies such as UNICEF, the World Health Organisation and the United Nations Development Programme.

The Somali government said 15 people were killed in the attack, including four foreign security staff.