The United States "strongly condemns" a Shebab attack that killed three soldiers and a civilian at African Union headquarters in Somalia, the State Department said Friday.

The assault, launched by the country's Al-Qaeda-linked rebels in Mogadishu on Thursday, killed three soldiers from the union's local peacekeeping mission known as AMISOM, and a civilian contractor.

"These individuals sacrificed their lives in an effort to bring lasting peace and stability to Somalia," State Department deputy spokeswoman Marie Harf said in a statement.

"The United States strongly condemns the December 25 attack," she added.

Four Shebab rebels, who are fighting to topple Somalia's internationally-backed government, were killed and another four captured in the attack, officials said.

"Our support for the people of Somalia, the African Union Mission in Somalia and Somali government forces in their efforts to defeat al-Shabaab will not waver," Harf said, using an alternate spelling for the group.

"We express our deepest condolences to the families of the military and civilian personnel who were killed in this cowardly terrorist act," she added.

The Shebab said it carried out the attack against what it said were "Ugandan mercenaries."

Officials did not give the nationalities of the AMISOM troops who were killed, but a contingent of Ugandan soldiers is in charge of the base.

The AMISOM force, deployed since 2007, currently counts some 22,000 African Union troops.

They have managed to push Shebab militants out of the capital, but the Islamists still hold large swathes of territory in the south and center of the country.