President Museveni has condoled with the people of Iran and paid a glowing tribute to their late President Ebrahim Raisi, who was killed in a helicopter crash on May 19.
Mr Museveni said he could see a patriot in the former Iranian leader and that "we could easily see that Raisi was a dedicated worker", which he said were noticeable from "small things'.
"When he visited us recently, we finished the government bilateral functions late, as dusk was gathering," Mr Museveni, who signed a condolence book at the Iranian High Commission in Kampala, said.
"However, he insisted on going to the suburbs at night to visit the pro-people projects Iran had constructed. From there, at night, HE Raisi, a Shia, visited Old Kampala mosque which belongs to the Sunni sect."
The late Raisi visited Uganda on July 12 last year during his tri-nation tour of Africa that he wrapped up in Zimbabwe after Kenya.
In Uganda, he had shocked many by remaining humble, taking a small convoy and almost letting his entire guard down to the extent of asking for coffee from a local attendant and taking it without a care.
He also used the visit to Uganda to lash at the West for promoting homosexuality in order to end what he called the "generation of human beings."
Speaking through an interpreter, Raisi described homosexuality as an attack against the establishment of the family and inheritance -- an area, he said, in which Uganda and Iran can cooperate.
"The Western countries try to identify homosexuality as an index of civilization, while this is one of the dirtiest issues," he said.
President Museveni's government could not have easily forgotten the gesture and support from the former Iranian strongman, with international relations minister Okello Oryem earlier describing him a "key ally" and a "true leader" who forged "historical relations with Uganda".
"Iran might be perceived in a different light elsewhere but we are a sovereign country that makes its own friends and enemies," Mr Oryem said.
"So we extend our sympathies to the Iranian people about this loss. We urge the people of Iran to stay calm as they mourn during this five-day period and as they also work out a transition. As usual we shall be looking forward to working with the next President."
President Museveni described the former Iranian leader as a "unifier for his country and for the Tri-continental struggle for justice by Asia, Africa, and Latin America and the peace-loving People of Europe".
"On behalf of the People of Uganda, I want to express the most heartfelt condolences to the friends and People of Iran on the death of their President, H.E Ebrahim Raisi," Mr Museveni wrote on his condolence message.
"I could see a patriot in His Excellency. It is a pity he died prematurely. May his soul rest in eternal peace."
President Raisi, foreign minister Hossein Amir-Abdollahian, and four other officials were killed when a helicopter they were travelling in crashed near the village of Uzi in East Azerbaijan province.
The helicopter carrying Raisi was heading to the city of Tabriz after returning from a dam opening ceremony on the Azerbaijan border.
The cause of the crash remains unclear, but the Chief of Staff of Iran's Armed Forces Maj Gen Mohammad Hossein Bagheri has launched an investigation, according to state media.