Uganda’s Constitutional Court on Wednesday largely upheld a sweeping anti-gay law that President Yoweri Museveni signed last year, undermining the efforts of activists and rights groups to abolish legislation that drew worldwide condemnation and strained the East African nation’s relationship with the West.

The legislation, which was signed into law by Mr. Museveni in May, 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.

Uganda has faced international consequences for passing the law, with the World Bank suspending all new funding and the United States imposing sanctions and visa restrictions on top Ugandan officials. But the law was popular in Uganda, a landlocked nation of over 48 million people, where religious and political leaders frequently inveigh against homosexuality.

The fallout for Uganda will be watched closely in other African countries where anti-gay sentiment is on the rise and anti-gay legislation is under consideration, including in Kenya, Namibia, Tanzania and South Sudan. In February, Ghana’s Parliament passed an anti-gay law, but the country’s president said that he would not sign it until the Supreme Court ruled on its constitutionality.

In Uganda, the five-judge bench said the law violated several key rights granted in the country’s Constitution, including the right to health and privacy. They also struck down sections of the law that criminalized failing to report homosexual acts, allowing any premises to be used to commit homosexuality or giving someone a “terminal illness” through gay sex.

But in their 200-page judgment, the judges largely rejected the request to quash the law.

“We decline to nullify the Anti-Homosexuality Act 2023 in its entirety, neither will we grant a permanent injunction against its enforcement,” Richard Buteera, one of the judges, said in a reading of the judgment’s summary to a packed courtroom. He added, “The upshot of our judgment is that this petition substantially fails.”

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.

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 United Nations, along with local and international human rights groups, said that the law conflicted with Uganda’s Constitution and that it would most likely be used to harass and intimidate its L.G.B.T.Q. population.

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.

Convening for Equality, a coalition of human rights groups in Uganda, has documented hundreds of rights violations and abuses, including arrests and forced anal examinations. Gay and transgender Ugandans have also been evicted from their homes and beaten up by family members — forcing many to flee to neighboring countries like Kenya.

The law’s passage brought swift repercussions for Uganda, too. Health experts also worried the law would hinder medical access for gay people, especially those seeking H.I.V. testing, prevention and treatment.

The United States said it would restrict visas for current and former Ugandan officials who were believed to be responsible for enacting the anti-gay policy. The Biden administration also issued a business advisory for Uganda and removed the country from a special program that allows African products duty-free access to the United States.

The World Bank, citing the anti-gay law, also said in August it would halt all future funding to Uganda. The economic pressures continued to pile on, with foreign travelers and investors staying away from Uganda.

Ahead of the ruling, Mr. Museveni remained publicly defiant, but analysts and diplomats said he privately worried about his country’s being labeled an outcast, and the devastating economic repercussions it was causing.

On Wednesday, members of the L.G.B.T.Q. community said the court’s judgment would not only amplify the government’s antagonism toward gay people but also deepen the animosity they face from members of the public.

The court’s decision opens a “Pandora’s box” that will push the lives of gay Ugandans “further more into darkness,” said Steven Kabuye, a gay rights advocate who fled to Canada after he was stabbed in January in an attack that activists said was spurred by homophobia linked to the law.

“I feel very disappointed but not surprised,” Mr. Kabuye said in a telephone interview.

"Exciting news! TheNigeriaLawyer is now on WhatsApp Channels 🚀 Subscribe today by clicking the link and stay updated with the latest legal insights!" Click here! ....................................................................................................................... Unauthorized use and/or duplication of this material and other digital content on this website, in whole or in part, without express and written permission from TheNigeriaLawyer, is strictly prohibited _________________________________________________________________

 To Register visit https://schoolofadr.com/how-to-enroll/ You can also reach us via email: info@schoolofadr.com or call +234 8053834850 or +234 8034343955. _________________________________________________________________

NIALS' Compendia Series: Your One-Stop Solution For Navigating Nigerian Laws (2004-2023)

Email: info@nials.edu.ng, tugomak@yahoo.co.uk, Contact: For Inquiry and information, kindly contact, NIALS Director of Marketing: +2348074128732, +2348100363602.