The victim, Charles Engola, served in the government of President Yoweri Museveni as the junior minister in charge of labor. He was a retired army colonel.
The attacker, who has not been publicly identified, then shot himself, according to state broadcaster UBC and others.
The shooting took place inside Engola's home in a suburb of the Ugandan capital, Kampala. Police detectives are now at the crime scene.
The motive was not immediately clear, but the local press said there had been an apparent dispute over the guard's wages.
“Witnesses claim that the soldier was yelling that he had not been paid for a long time despite working for a minister,” the online newspaper NilePost reported.
The incident is likely to send shockwaves in a country where other high-profile officials have been killed in gun attacks over the years.
In 2021, a former army chief in Uganda was wounded and his daughter killed when gunmen shot at their vehicle in Kampala.