It ruled that the bill was passed by MPs in December without the requisite quorum and was therefore illegal.
Homosexual acts were already illegal, but the new law allowed for life imprisonment for "aggravated homosexuality" and banned the "promotion of homosexuality".
Several donors have cut aid to Uganda since the law was adopted.
Journalist and one of the challengers
Uganda is a deeply conservative society where many people oppose gay rights and the sentence for homosexual acts has always been life imprisonment.
Earlier drafts of the anti-homosexuality act made it a crime not to report gay people - which would have made it impossible to live as openly gay - but this clause was removed.
However the legislation that was passed in parliament was "null and void", the presiding judge at the Constitutional Court said, as not enough lawmakers had been present to vote on the bill.
The law, which was signed by President Yoweri Museveni in February, toughened up existing laws.
Lesbians were covered for the first time and those found living in a same-sex marriage could have been sentenced to life imprisonment.
The challenge to the law was brought by 10 petitioners, including academics, journalists, both ruling and opposition MPs, human rights activists and rights groups.
"The retrogressive anti-homosexuality act of Uganda has been struck down by the constitutional court - it's now dead as a door nail," the AFP news agency quotes prominent journalist Andrew Mwenda, one of the petitioners, as saying.