The legislation calls for life imprisonment for anyone who engages in gay sex. Anyone who tries to have same-sex relations could face up to a decade in prison.
The five-judge bench largely rejected the request to quash the law although they said it law violated several key rights granted in the country’s Constitution, including the right to health and privacy.
“We decline to nullify the Anti-Homosexuality Act 2023 in its entirety and neither will we grant a permanent injunction against its enforcement,” Richard Buteera, the deputy chief justice, said in a reading of the judgment’s summary to a packed courtroom.
In particular, the court said the section of the legislation requiring the mandatory reporting to authorities of people suspected of having committed homosexual offences violated individual rights.
When the law was enacted in May 2023 the World Bank halted new lending to Uganda and the United States announced visa and travel restrictions against Ugandan officials.
The Anti-Homosexuality Act imposes penalties of up to life imprisonment for consensual same-sex relations and contains provisions that make “aggravated homosexuality” an offence punishable by death.
Passage of the law — which also imposes harsh fines on organizations convicted of promoting homosexuality — alarmed human rights advocates, who said it would give new impetus for the introduction of equivalent draconian laws in other African nations. Uganda is among the African countries that already ban gay sex, but the new law creates additional offenses and prescribes far more punitive penalties.
The ratification of the Anti-Homosexuality Act, as the law is officially known, renewed scrutiny of the government of Mr. Museveni, who has ruled Uganda with a tight grip for almost four decades. Mr. Museveni, his son — whom he recently appointed as head of the army — and other top members of his government have been accused of detaining, beating, torturing and disappearing critics and opposition members.
The law was first introduced in March last year by a lawmaker who said that homosexuality was becoming pervasive and threatening the sanctity of the Ugandan family. Some legislators also claimed that their constituents had notified them of alleged plans to promote and recruit schoolchildren into homosexuality — accusations that rights groups said were false.
Anti-gay sentiment is prevalent among Muslim and Christian lawmakers and religious leaders from both faiths. They say that homosexuality is a Western import, and they held rallies to show support for the law before it passed.
A few weeks after it was introduced in Parliament, the law was quickly passed with only two lawmakers opposing it.
Activists, academics and human rights lawyers who challenged the law in court said it contravened not only Uganda’s Constitution, which guarantees freedom from discrimination, but also international treaties, including the African Charter on Human and Peoples’ Rights. They also argued that Parliament passed the law too quickly, with not enough time allowed for public participation — arguments the judgments rejected in their decision.
Human rights groups said that since the law was introduced and passed, L.G.B.T.Q. Ugandans have faced intensive violence and harassment.
Frank Mugisha, a prominent gay rights activist and one of the petitioners, said that they would appeal the Constitutional Court’s decision to the Supreme Court.
“I am very sad,” Mr. Mugisha said in a telephone interview. “The judges have been swayed by the propaganda from the anti-gay movement who kept saying that this is in the public interest and refuting all the arguments that we made that relate to the Constitution and international obligations.”
The law in Uganda decrees the death penalty for anyone convicted of “aggravated homosexuality,” a sweeping term defined as acts of same-sex relations with minors or disabled people, those carried out under threat or while someone is unconscious. Even being accused of what the law refers to as “attempted aggravated homosexuality” carries a prison sentence of up to 14 years.