World Bulletin/News Desk
Somali militant group al Shabaab claimed responsibility for the attack, which lasted several hours, and said it had killed 14 peacekeepers. Witnesses reported hearing bomb blasts and volleys of gunfire through the day.
In the past, al Shabaab has exaggerated the number of soldiers it has killed, while officials have played down losses.
The raid showed al Shabaab's ability to carry out high-profile attacks in the capital even as it is losing territory in rural areas to AU peacekeepers who have launched two major offensives this year.
"The terrorists, some of whom were disguised in Somali National Army uniforms, breached the base camp around lunch hour and attempted to gain access to critical infrastructure, during which five of them were killed and three others captured," the AU peacekeeping mission in Somalia, AMISOM, said in a statement.
It did not disclose the nationalities of the peacekeepers and civilian contractor killed in the attack.
The AU's Halane base is on the edge of the Mogadishu international airport compound, which houses the base for U.N. operations in Somalia as well as the British and Italian embassies and has a tight security cordon and blast walls.
Western diplomats who were celebrating Christmas in the sweltering Mogadishu heat were evacuated to safety bunkers until the raid was over.
A spokeswoman for the U.S. State Department, Marie Harf, called the attack "a cowardly terrorist act", and said U.S. support for the people of Somalia, the African Union Mission in Somalia, and Somali government forces in their efforts to defeat al-Shabaab would not waver.
Al Shabaab was pushed out of Mogadishu in 2011 but it still controls chunks of the countryside in south and central Somalia. This year it has lost several key towns, including the port city of Barawe, during the two AMISOM offensives.