First introduced in parliament in 2009 as a private member's bill, the law initially proposed the death penalty for some homosexual acts in the conservative east African country.
It was later amended to remove the death penalty, but includes jail terms for anyone convicted, including life imprisonment for what it calls aggravated homosexuality.
Countries including the United States previously criticised the bill when it came before parliament. Germany cut off aid to Uganda late last year citing the bill as one of its concerns.
Widespread criticism of the law, and resistance from the executive, which is wary of antagonising Western donors, stalled its passage. But parliament has also been under pressure to push it through, especially from mainstream and evangelical churches.
Homosexuality was already illegal in Uganda, but the new law prohibits the "promotion" of gay rights and punishes anyone who "funds", "sponsors" or "abets" homosexuality.
Homosexuality is taboo in many African countries. It is illegal in 37 nations on the continent, and activists say few Africans are openly gay, fearing imprisonment, violence and losing their jobs.
Frank Mugisha, executive director of Sexual Minorities Uganda, said he would try to rally rights activists to have the law blocked in the courts.
The president must sign any bill before it is made law.