The attack was claimed by the al-Shabab, the military branch of the Union of Islamic Courts, that briefly controlled large parts of Somalia before being ousted last year by Ethiopian forces supporting the Somali transitional government.
In a statement posted on their website, the al-Shabab said the attack was the largest since the Ugandans were deployed to Mogadishu in March 2007.
"The Shabab mujahidin carried out an attack against the Ugandan invaders," the statement said.
"Our attack was launched from four directions ... It was the heaviest attack ever on K4 where the Ugandans are based."
According to several witnesses, at least 11 civilians were killed in the exchange of fire.
"My son was among eight civilians killed by a heavy artillery shell that smashed into a building where they were all hiding, trying to avoid the crossfire," Muktar Husein Ali, a local resident, said.
Another local resident gave the same death toll.
"About eight dead bodies were pulled out from a building that was destroyed by an artillery shell. Most of the victims were torn to pieces," Asha Mohamed said.
Several other witnesses said the fierce clashes, which broke out shortly before 7.00pm (1600 GMT), left another two civilians dead.
"I saw two young boys killed by an explosion as they were chewing Khat [a mild narcotic leaf] behind the Ambassador Hotel," Farah Abdi Warsame said.
According to witnesses, a child caught in the crossfire was also killed in the nearby Taleh area.