NAIROBI, Kenya — Gunmen attacked the African Union’s main base in the capital, Mogadishu, on Thursday leading to gunfire between militants and soldiers that left at least five militants dead, an official with the mission in Somalia said.

Somali extremist group al-Shabab claimed responsibility for the attack and said they were targeting a Christmas party at the base, which also houses Western embassies and U.N. offices.

At least eight men entered the AU base near the Mogadishu airport, AU spokesman Col. Ali Aden Houmed said.

“Our forces shot dead three of them, two detonated themselves near a fuel depot, and three are believed to have escaped,” he said.

Some African Union soldiers may have died in the fighting, Houmed said, but did not give details. “An investigation is underway on how they entered the base,” he said, adding that the attack was launched at a time when people were busy at lunch.

AU troops are bolstering Somalia’s weak government against an insurgency from the al-Qaida-linked al-Shabab.

This is not the first time al-Shabab has moved against the African Union, including a 2011 attack on an AU base in Mogadishu that killed at least 10. Earlier this month, a suicide bomber rammed his vehicle into a U.N. convoy near Mogadishu’s airport, killing three.

The attacks underscore the militants’ ability to carry out complex and deadly operations even after AU troops forced them from strongholds.