Friday's incident involving the convoy of Brigadier Paul Lokech, who heads the Ugandan contingent of the African Union Mission in Somalia (AMISOM), happened when Somali soldiers established road blocks to lock down the capital after two bomb blasts that killed dozens of people.
Uganda's military spokesperson Brigadier Richard Karemire said Somali troops fired at the convoy and its soldiers retaliated in self-defence.
"There is absolutely no reason why the AMISOM forces in their designated sector of responsibility should have been blocked and fired at en route back to the base after providing critical support and with some victims of the attack being quickly evacuated for urgent medical attention," he said.
"As the incident is being investigated, let it be clear that AMISOM rules of engagement provide for self-defence and anyone who fires at these forces becomes a target," he added.
AMISOM on Saturday had said some of its troops "transporting injured civilians... were involved in an incident" at a National Intelligence and Security Agency (NISA) checkpoint near Kilometre-4, the city's main junction.
"The incident is under investigation by both the federal government of Somalia and AMISOM," it said in a statement.
This is not the first incident of deadly friendly fire between AU and Somali security forces in Mogadishu.
Friday's first bombing was at an entrance to the hilltop presidential palace complex while a second explosion hit a hotel close to the NISA headquarters, the presumed target.
The bombings were claimed by the al-Qaeda linked Shabaab militants who are fighting to overthrow the internationally-backed government in Mogadishu, which is defended by 22 000 AMISOM troops, including 6 000 Ugandans.