A presidency photo showed Museveni signing the law with a golden pen at his desk. The 78-year-old has called homosexuality a "deviation from normal" and urged lawmakers to resist "imperialist" pressure.
A local organization, the Human Rights Awareness and Promotion Forum, and 10 other individuals later filed a complaint against the law at the constitutional court, one of the petitioners Busingye Kabumba told Reuters.
Same-sex relations were already illegal in Uganda, as they are in more than 30 African countries, but the new law imposes capital punishment for some behavior including having gay sex when HIV-positive, and stipulates a 20-year sentence for "promoting" homosexuality.
Museveni had urged lawmakers to resist "pressure from the imperialists" and parliament speaker Anita Among congratulated her colleagues on Monday.
"With a lot of humility, I thank my colleagues the Members of Parliament for withstanding all the pressure from bullies and doomsday conspiracy theorists in the interest of our country," she said in a statement.
"The Ugandan president has today legalized state-sponsored homophobia and transphobia," said Clare Byarugaba, a Ugandan rights activist. "It's a very dark and sad day for the LGBTIQ community, our allies and all of Uganda."
She and other activists have vowed a legal challenge to the law, which Museveni was shown signing at his desk with a golden pen in a photo tweeted by Uganda's presidency. The 78-year-old leader has called homosexuality a "deviation from normal."
Uganda's LGBTQ community is afraid: many have closed down social media accounts and fled homes for safe houses.
Some are looking to go abroad.
United States President Joe Biden called the move "a tragic violation" of human rights and said Washington would evaluate the implications of the law "on all aspects of U.S. engagement with Uganda."
"We are considering additional steps, including the application of sanctions and restriction of entry into the United States against anyone involved in serious human rights abuses or corruption," he said.
Museveni had sent the original bill back to lawmakers, asking that they tone down some provisions. The amended version stipulated that merely identifying as LGBTQ is not a crime and revised a measure that obliged people to report homosexual activity to only require reporting when a child is involved.
A less restrictive 2014 anti-LGBTQ law was struck down by a domestic court on procedural grounds, after Western governments had initially suspended some aid, imposed visa restrictions and curtailed security cooperation.
Uganda receives billions of dollars in foreign aid each year and could now face another round of sanctions.
Three major health initiatives - the Global Fund to Fight AIDS, Tuberculosis and Malaria, the Joint United Nations Program on HIV/AIDS (UNAIDS) and the U.S. President's Emergency Plan for AIDS Relief (PEPFAR) - issued a statement saying the law put Uganda’s anti-HIV fight "in grave jeopardy."
The new law could encourage lawmakers in neighboring Kenya and Tanzania seeking similar measures.
Forum