Uganda’s parliament said on Twitter that Museveni had approved a new draft of the legislation that was passed overwhelmingly by lawmakers in the East African nation earlier this month.
MPs had vowed to resist outside pressure over the bill, which they cast as interference in an effort to protect Uganda’s national culture and values from Western immorality.
Museveni had called on parliament to rework the bill, although most of the hardline provisions that caused an outcry in the West were retained.
The amended version said that identifying as gay would not be criminalised but “engaging in acts of homosexuality” would be an offence punishable with life imprisonment.
Although Museveni had advised lawmakers to delete a provision making “aggravated homosexuality” a capital offence, lawmakers rejected that move, meaning that repeat offenders could be sentenced to death.
Uganda has not resorted to capital punishment for many years.
The UN Human Rights Office — whose commissioner Volker Turk in March described the bill as “among the worst of its kind in the world” — condemned its passage into law.
“It is a recipe for systematic violations of the rights of LGBT people & the wider population,” it said on Twitter.
Ashwanee Budoo-Scholtz, Africa deputy director for Human Rights Watch, told AFP it was “discriminatory and is a step in the wrong direction for the protection of human rights for all people in Uganda”.
But the legislation enjoys broad public support in devout, majority Christian Uganda, which has pursued among the toughest anti-gay legislation in Africa where around 30 nations ban homosexuality.
“As Parliament of Uganda, we have heeded the concerns our people and legislated to protect the sanctity of family,” the assembly’s speaker Anita Among, one of the bill’s strongest proponents, said in a statement.
“We have stood strong to defend the culture, values and aspirations of our people.”
Living in fear
Discussion of the bill in parliament was laced with homophobic slurs, and Museveni himself referred to gay people as “deviants”.
Frank Mugisha, executive director of Sexual Minorities Uganda, said the law would “bring a lot of harm” to the country’s already-persecuted LGBTQ community.
“We feel so, so, so worried,” he says.
The revised bill said “a person who is believed or alleged or suspected of being a homosexual, who has not committed a sexual act with another person of the same sex, does not commit the offence of homosexuality”.
An earlier version also required Ugandans to report suspected homosexual activity to the police or face six months’ imprisonment.
Lawmakers agreed to amend that provision and instead the reporting requirement pertained only to suspected sexual offences against children and vulnerable people, with the penalty raised to five years in jail.
Anyone who “knowingly promotes homosexuality” faces up to 20 years in jail — a provision left unchanged from the original bill — while organisations found guilty of encouraging same-sex activity could face a 10-year ban.
Reaction from civil society in Uganda has been muted following years of erosion of civic space under Museveni’s increasingly authoritarian rule.
But internationally, the law provoked outrage.
The European Parliament voted in April to condemn the bill and asked EU states to pressure Museveni into not implementing it, warning that relations with Kampala were at stake.
The White House also warned the government of possible economic repercussions if the legislation took effect.
A 2014 anti-gay bill signed into law by Museveni but later struck down prompted foreign aid cuts by Western nations, and diplomats have warned similar measures are being considered now.
Asuman Basalirwa, the MP who sponsored the bill, said aid cuts were expected and that Among, the parliament speaker, had already been informed her US visa had been revoked.
The bill also risked undermining progress in combating HIV/AIDS in Uganda, warned UNAIDS, the Global Fund to Fight AIDS, Tuberculosis and Malaria, and the US President’s Emergency Plan for AIDS Relief (PEPFAR).
Homosexuality was criminalised in Uganda under colonial laws, but there has never been a conviction for consensual same-sex activity since independence from Britain in 1962.
Understand Africa's tomorrow... today
We believe that Africa is poorly represented, and badly under-estimated. Beyond the vast opportunity manifest in African markets, we highlight people who make a difference; leaders turning the tide, youth driving change, and an indefatigable business community. That is what we believe will change the continent, and that is what we report on. With hard-hitting investigations, innovative analysis and deep dives into countries and sectors, The Africa Report delivers the insight you need.