"We have not killed any civilians but aimed at those who attack us using small arms."
A contingent of 1,600 Ugandan peacekeepers and 600 Burundian troops, known as Amisom, has been unable to stem mounting violence in Somalia.
Somali and Ethiopian troops have routinely been targeted since the Islamic Courts movement was ousted from Mogadishu in a short war in late 2006 and early 2007.
Monday's attack on the Ugandan base in Mogadishu was claimed by the al-Shabab, the military branch of the Union of Islamic Courts.
Elsewhere, in Somalia's southern Gedo region, Somali fighters fired at elders trying to broker a peace deal between rival clans, killing five elders, witnesses said.
The armed men raided the meeting of the Marehan and Luway clans, whose delegates were seeking an end to a land dispute, and opened fire, the witnesses said.
"Militia from Luway clan opened fire ... killing five of them on the spot. Seven others have been seriously wounded," said Abdiqani Adan Dahir, chairman of the Marehan elders committee.
He said all the slain elders were from his clan.