The bill would also make it a crime punishable by imprisonment not to report gay people to police, the BBC reported Friday.
Ugandan Prime Minister Amama Mbabazi opposed the vote, saying there were not enough parliament members present.
It remains to be seen whether President Yoweri Museveni will sign the bill into law, the BBC said.
The bill initially proposed the death penalty for homosexual acts with a minor or if the perpetrator was HIV positive, but that element was dropped.
Human rights activists opposed what they called the bill's intolerance and discrimination, and U.S. President Barack Obama called it "odious."
Millions of Getty images now available for free via embed tool
NBC reportedly holds celebs hostage to Jimmy Fallon's show