The anti-gay bill also makes it a crime punishable by a prison sentence not to report gay people.
Uganda’s PM Amama Mbabazi opposed the vote, saying not enough MPs were present.
The bill has been condemned by world leaders since it was mooted in 2009 with President Barack Obama calling it “odious”.
The government knows there will be an international outcry, which could see some countries suspend aid to the country.
Amama Mbabazi might follow up on his complaints about a lack of quorum, while it remains to be seen whether President Yoweri Museveni will sign the bill into law.
The private member’s bill originally proposed the death penalty for some offences, such as if a minor was involved or the perpetrator was HIV-positive, but this has been replaced with life in prison.
The MP behind the bill, David Bahati, told the AFP news agency: “This is victory for Uganda. I am glad the parliament has voted against evil.”
“Because we are a God-fearing nation, we value life in a holistic way. It is because of those values that members of parliament passed this bill regardless of what the outside world thinks,” he said.
The bill’s supporters say it is needed to protect traditional family values, which they say are under attack from Western-inspired gay rights groups.
Its critics say the bill has been pushed by some US evangelical Christians.
Holidaymakers and visiting foreigners are not immune from prosecution under Uganda’s existing anti-gay laws.
Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…