Ugandan soldiers hid for six days before being rescued after al-Shabab militants overran their base, a spokesperson for the Uganda Peoples' Defense Forces (UPDF) told VOA Somali.
Brigadier General Felix Kulaigye said the four soldiers, including a lieutenant, survived by hiding within and around the base in the town of Bulo Marer, 110 kilometers south of Mogadishu.
He said the troops were found after the Ugandan contingent retook the base on Thursday.
"When we recovered, they were weak because they were only surviving on urine," Kulaigye said.
He said each of the soldiers was hiding alone, in separate locations.
"They were weak out of hunger," he said.
"The lieutenant had been wounded, his leg was in bad shape and they have been treated in hospital, but they are promising to recover very well."
The news comes as President Yoweri Museveni disclosed that 54 Ugandan soldiers were killed in the May 26 attack.
"We discovered the lifeless bodies of fifty-four fallen soldiers, including a Commander," Museveni said in a tweet.
Uganda sent a team led by land forces commander Lieutenant General Kayanja Muhanga to Somalia to investigate the attack.
Museveni singled out two commanders for making a "mistake" by ordering the soldiers to retreat.
"They have been apprehended and will face charges in the Court Martial," Museveni said.
The al-Shabab militant group on Monday published a video purportedly from the raid on the UPDF base. In the video, the leader of al-Shabab, Ahmed Umar Abu Ubaidah, whose face is blurred, sends off the attackers.
Officials said Ugandans were heartbroken and shocked by the news that 54 of their soldiers were killed.
Ugandan diplomat and former deputy head of the Africa Union Mission in Somalia, Simon Mulongo, who is now a security analyst, said people received the news of the attack and overrunning of the base by militants with shock.
"They felt their deaths were cruel," he told VOA Somali.
"Uganda had never suffered such a deadly attack. There has been some attacks or attempted attacks and probing attacks, but we never lost some high number. And as such, it took us by shock."
Mulongo also said the attack generated debate on whether to withdraw troops from Somalia or keep them to let the mission "pursue its objectives to its logical conclusion."
"It's a kind of mixed reaction but in both cases, it's with pain," Mulongo added.
Kulaigye observed similar mixed reactions.
"Some urge us to go on and make sure we revenge," he said.
"Others felt the mission should get out because we are dying for other people, not for our country; and for us, we are saying we have to keep [troops] in [Somalia] so that the entire Africa is peaceful."
Kulaigye said Uganda will not withdraw troops from Somalia unless the Africa Union asks them to do so.
"These casualties do not discourage our pan-African duty," he said. "We do not take these attacks lightly; when you attack us, we bring the war to you as well."
Mulongo says Uganda does not share a border with Somalia, but its commitment is "total."
"We are there purely on humanitarian grounds, and [are the] best on pan Africanism as a driving philosophy," he said.
"We believe that stable Somalia is the only alternative we can have of a neighbor with whom we can bloc in terms of economics, in terms of trade, in terms of technological transfer; and to benefit from them since they occupy a strategic position in the eastern region."