A Ugandan court has overturned a strict anti-gay law on the grounds that the bill was passed without having gone through necessary legal proceedings.

Ugandans opposed to the law filed a constitutional petition alleging that the law violated fundamental rights.

The presiding judge told the constitutional court the bill was "null and void" and that it had compromised the Ugandan constitution.

The anti-gay bill, which had been disputed by international rights groups, was signed into law in December by President Yoweri Museveni. 

It said that homosexuals should be jailed for life, outlawed the promotion of homosexuality and obliged Ugandans to denounce gays to the authorities.

"I can confirm the anti-homosexuality law has been struck down. The judge said there were irregularities in the process of its enactment and also there was no quorum in parliament," said Nicholas Opio, a lawyer for the petitioners.  

But homosexuality remains illegal and punishable by jail sentences under previous legislation, which is expected to be returned after the court's decision.

US Secretary of State John Kerry had likened the law to anti-Semitic legislation in Nazi Germany.

Critics have said Mr Museveni signed the law to win domestic support ahead of a presidential election scheduled for 2016, which will be his 30th year in power.

But Western nations made a raft of aid cuts to Uganda's government in protest since the law was passed.

Rights groups say the law triggered a sharp increase in arrests and assaults of members of the country's lesbian, gay, bisexual and transgender (LGBT) community.

Executive Director of Amnesty International Ireland Colm O'Gorman said the decision is a significant victory for Ugandan activists.

He said: "We now hope that this step forward translates into real improvements in the lives of lesbian, gay, bisexual, transgender, and intersex people in Uganda, who have been trapped in a vicious circle of discrimination, threats, abuse and injustice for too long".