Ugandan MPs have passed an anti-gay bill that calls for life imprisonment for certain homosexual acts, drawing criticism from rights campaigners who called it "the worst in the world".
When the bill was first introduced in 2009, it was widely condemned for including the death penalty, but that was removed from the revised version passed by parliament.
Instead it sets life imprisonment as the penalty for a homosexual act where one of the partners is infected with HIV, sex with minors and the disabled, as well as repeated sexual offences among consenting adults, according to the office of a spokeswoman for Uganda's parliament.
The bill also prescribes a seven-year jail term for a person who "conducts a marriage ceremony" for same-sex couples.
The bill was passed unanimously by the parliament, with no one voicing an objection.
President Yoweri Museveni must sign the bill within 30 days for it to become law. Although in the past he spoke disparagingly of gays, in recent times Mr Museveni has softened his position on the matter, saying he is only opposed to gays who appear to "promote" themselves.
"In our society there were a few homosexuals," Mr Museveni said in March. "There was no persecution, no killings and no marginalisation of these people but they were regarded as deviants. Sex among Africans including heterosexuals is confidential. If I am to kiss my wife in public, I would lose an election in Uganda."
The passage of the bill makes it "a truly terrifying day for human rights in Uganda," said Frank Mugisha, a prominent Ugandan gay activist, who called the legislation "the worst anti-gay law in the world." He urged the country's president not to sign the legislation into law.
"It will open a new era of fear and persecution," he said. "If this law is signed by President Museveni, I'd be thrown in jail for life and in all likelihood killed."
Homosexuality was already illegal in Uganda under a colonial-era law that criminalised sexual acts "against the order of nature," but the MP who wrote the new legislation argued that tougher legislation was needed because homosexuals from the West threatened to destroy Ugandan families and were allegedly "recruiting" Ugandan children into gay lifestyles.
Ugandan gays disputed this account, saying that Ugandan political and religious leaders had come under the influence of American evangelicals who wanted to spread their anti-gay campaign in Africa. Ugandan gays singled out Scott Lively, a Massachusetts evangelical, and sued him in March 2012 under the Alien Tort Statute that allows non-citizens to file suit in the United States if there is an alleged violation of international law.
Despite criticism of the anti-gay legislation abroad, it is highly popular among Ugandans who say the country has the right to pass laws that protect its children.
David Bahati, the MP who wrote the bill, said in a Facebook update today that the legislation was necessary "to defend our culture and to defend the future of our children".
When the bill was first proposed, United States president Barack Obama called it "odious".
Maria Burnett, a senior Africa researcher with Human Rights Watch, said the bill is "still appalling" despite some amendments.
Homosexuality remains a taboo subject across many parts of Africa. Some 38 African countries - about 70% of the continent - criminalise homosexual activity, Amnesty International said in a report released earlier this year.