The ruling was an embarrassment for Jaroslaw Kaczynski, the prime minister, and his twin Lech, Poland's president, who have made the law a cornerstone of their political agenda.
The brothers have exerted pressure on the tribunal in the past few days, accusing its members of being part of a post-communist "network" opposed to a clean break with the past.
The president said: "This issue is not over," after he heard the verdict.
The law required hundreds of thousands of Poles, including academics, journalists, government officials and heads of listed companies, to state in writing whether they co-operated with communist-era spies.
Collaborator or not, anyone found to have made a false statement could be banned from their jobs for 10 years - a point the court said was unconstitutional.
Thousands of Poles, backed up by members of the European Parliament, decried the law as a "witch hunt" by the Kaczynskis' ruling conservatives against their political opponents.
Jan Rokita, an opposition leader with the centre-right Civic Platform, said: "This is a total fiasco."
The tribunal agreed with critics who said it failed to distinguish between real collaborators and those who were victims of the communist secret service.
Mere contact with an agent could be construed as collaboration under the law.