By RODNEY MUHUMUZA, Associated Press

KAMPALA, Uganda (AP) — A Ugandan court on Friday invalidated an anti-gay bill signed into law earlier this year, saying the measure is illegal because it was passed during a parliamentary session that lacked a quorum.

Activists erupted in cheers after the court ruled the law "null and void," but some cautioned that the fight was not over: The state could appeal the ruling in the Supreme Court and legislators might try to reintroduce new anti-gay measures.

The law provided jail terms up to life for those convicted of engaging in gay sex. It also allowed lengthy jail terms for those convicted of the offenses of "attempted homosexuality" as well as "promotion of homosexuality."

Although the legislation has wide support in Uganda, it has been condemned in the West and rights groups have described it as draconian.

The U.S. has withheld or redirected funding to some Ugandan institutions accused of involvement in rights abuses, but the ruling Friday might win the Ugandan delegation a softer landing in the U.S. next week as it heads to Washington for a gathering led by President Barack Obama.

The panel of five judges on the East African country's Constitutional Court said the speaker of parliament acted illegally when she allowed a vote on the measure despite at least three objections — including from the country's prime minister — over a lack of a quorum when the bill was passed on Dec. 20.

"The speaker was obliged to ensure that there was a quorum," the court said in its ruling. "We come to the conclusion that she acted illegally."

The courtroom was packed with Ugandans opposing or supporting the measure.

Frank Mugisha, a Ugandan gay leader, said the ruling was a "step forward" for gay rights even though he was concerned about possible retaliation.

Ugandan lawyer Ladislaus Rwakafuuzi, an attorney for the activists, said the ruling "upholds the rule of law and constitutionalism in Uganda."

Lawyers and activists challenged the anti-gay law after it was enacted in February on the grounds that it was illegally passed and that it violated certain rights guaranteed in Uganda's constitution.

The court ruled Friday that the activists' entire petition had been disposed of since the law was illegally passed in the first place. This means there will be no further hearings about the activists' argument that the anti-gay measure discriminated against some Ugandans in violation of the constitution.

Nicholas Opiyo, a Ugandan lawyer who was among the petitioners, welcomed the ruling but said there is a missed opportunity to debate the substance of the law. "The ideal situation would have been to deal with the other issues of the law, to sort out this thing once and for all," Opiyo said.

A colonial-era law that criminalizes sex acts "against the order of nature" still remains in effect in Uganda, allowing for the continued arrests of alleged homosexual offenders, Opiyo said.

Lawmakers might also try to reintroduce a new anti-gay measure, he said.

Kosia Kasibayo, a state attorney, said a decision had not been made on whether to appeal the ruling in the Supreme Court, Uganda's highest court.

The anti-gay legislation was enacted on Feb. 24 by Ugandan President Yoweri Museveni, who said he wanted to deter Western groups from promoting homosexuality among African children.

Some European countries and the World Bank withheld aid over the law, piling pressure on Uganda's government, which depends on Western support to implement a substantial part of its budget. Ofwono Opondo, a Ugandan government spokesman, had repeatedly described Western action over the law as "blackmail." Opondo and other government officials were not immediately available for comment after the Friday ruling.

Supporters of the anti-gay measure say they believe Museveni — who will lead Uganda's delegation to the U.S. next week— may have quietly backed the court's ruling. Many Ugandans see the courts as lacking independence and unlikely to make decisions strongly opposed by Museveni, who has held power here for nearly three decades.

"This ruling has got nothing to do with the will of the people," said Martin Ssempa, a prominent Ugandan cleric who has led street marches in support of the anti-gay measure. "Unfortunately, it has everything to do with pressure from Barack Obama and the homosexuals of Europe."

Although Ugandan police say there have been no arrests of alleged homosexual offenders since the bill was enacted, gay leaders and activists say suspected homosexuals have been harassed by the police as well as landlords, sending many underground and unable to access essential health services. Ugandan police raided the offices of a U.S.-funded clinic that offered AIDS services to homosexuals after the bill was enacted.

The HIV prevalence rate among homosexual men in the Ugandan capital of Kampala is 13 percent, about double the national average, according to the U.S.-based advocacy group Health GAP. It said in a statement that the court's decision was "a crucial development for increased access" to life-saving health services.

"This is a great day for social justice," Michel Sidibé, the executive director of the United Nations AIDS agency, said of the Ugandan court's decision. "The rule of law has prevailed."