ByElias Biryabarema, ReutersAugust 2, 2014

Kampala, Uganda — Uganda's constitutional court on Friday overturned an anti-homosexuality law that punished gay sex with long prison sentences and was condemned by Western and other donors, some of whom withheld aid in protest.

The new ruling, which can be appealed, voids a statute signed into law by the president in February and which had broad support in the religiously conservative east African nation.

Under the Anti-Homosexuality Act, those convicted of "aggravated homosexuality" - defined as someone with HIV having gay sex or gay sex with anyone vulnerable, such as a disabled person - would be put in prison for life.

Citing irregularities in the way the law was passed, Judge Steven Kavuma said the speaker of parliament had acted illegally by not accepting objections pointing to the fact that there was no quorum for a vote.

"The Act itself so enacted by this reason alone is unconstitutional," he said.

Lawyers said the constitutional court ruling could be challenged through an appeals process.Fear of violence, imprisonment and loss of jobs mean few gays in Africa are open about their sexuality.

The United States, Uganda's biggest donor, called the legislation "atrocious," likening it to anti-Semitic laws in Nazi Germany and apartheid in South Africa. When it was passed, Washington said it would review relations with Kampala.

On Saturday, Musaeveni said that the court's decision was not in response to international pressure from the US or his pending trip.

“I was going to Washington with the bill when it was stopped. It has nothing to do with us going to Washington,” he said, according to Agence France Press. And he insisted that the freezing of aid has had no effect on the country. “What has happened to Uganda now? Have you seen any catastrophe? Isn’t the economy growing?” But homosexuality in Uganda remains illegal and punishable by jail sentences under previous legislation, which is expected to return after the court’s decision. The White House welcomed the court's decision.

"This is an important step in the right direction for human rights, not just of the LGBT (lesbian, gay, bisexual and transgender) community, but of all Ugandans," said Ned Price, a spokesman for the White House National Security Council.

Ethics and Integrity Minister Simon Lokodo, who has in the past said that aid should not be tied to Uganda's stand on homosexuality, declined to comment on the ruling.

The World Bank and some European donors - Norway, Denmark and the Netherlands - withheld aid or loans worth more than $118 million. Sweden resumed financial support to Uganda this week.

The Swedish embassy in Kampala said it would provide 1.35 billion crowns ($198 million) over the next five years to improve child and maternal health, sustainable growth and employment in the east African country.

"Sweden wants to help create better conditions in Uganda for sustainable economic growth and development. This is why Swedish aid to Uganda will remain substantial," Swedish Minister for International Development Cooperation Hillevi Engstrom said.

"Sweden continues to support human rights and freedom from violence", the embassy said in its English-language statement.

In a Swedish-language statement issued by the foreign ministry in Stockholm last Thursday, Engstrom also said: "I will specifically monitor the situation of women's rights and LGBT rights. It is important that LGBT people and others do not become scapegoats because of changes in Swedish aid."

Uganda relies on aid to fund about 20 percent of its budget.

The Ugandan shilling came under pressure when the law was passed. On Friday, it rose, with banks cutting long dollar positions on expectations of a resumption in aid.

WESTERN PRESSUREThe government had resisted Western pressure to rescind the law but in July Kampala said that donors had "misinterpreted" the measure, saying it was to prevent the promotion of gay sex to children, not to punish or ostracize homosexuals.

Ugandans opposed to the law had brought a petition to the constitutional court, saying that the law violated fundamental rights. This aspect was not addressed by the judge.

"I welcome the ruling although I would have loved the judge to go into the substance of our petition," said Frank Mugisha, executive director of Sexual Minorities Uganda.

"That's where he would have realized that the law violates the Constitution of Uganda and (I) am sure he would have gone ahead to declare homosexuality legal in Uganda."

The law also criminalized lesbianism for the first time and made it a crime to help individuals engage in homosexual acts.

"This decision is a bright spot in a dark record on human rights," Asia Russell, Uganda-based director of international policy at Health GAP, an HIV advocacy group.

During the bill signing, Museveni had said homosexuality was emblematic of the West's "social imperialism" in Africa. Powerful Christian groups with links to

U.S. evangelical groups have labeled homosexuality an imported Western social evil.

"We're wondering whether the ruling is in any way related to the president's travel to America because Obama has made it clear his No. 1 policy agenda is advancing homosexualism," said Pastor Martin Ssempa, one of the evangelical pastors who were most instrumental in pushing for the law. (Additional reporting by Roberta Rampton in Washington and by Elias Biryabarema and Sven Nordenstam in Stockholm; Writing by James Macharia; Editing by Edmund Blair/Mark Heinrich)