Poland's constitutional court has struck down sections of a controversial law aimed at uncovering collaboration with the communist-era secret police.
Many Poles approved of the vetting proposals
The law, which came into force in March, required up to 700,000 people to confess if they were informants.
But the country's highest court has decided that sections of the law violate Poland's constitution.
The law broadened existing rules on disclosing collaboration to "people filling a public function".
Previously, only senior public servants were required to reveal involvement with the secret police.
The new law would have also covered teachers, academics and journalists, who would have been barred from working for a public company for a decade if they refused to co-operate or lied.
The BBC's Adam Easton in Warsaw says the court's decision will be seen as damaging to Prime Minister Jaroslaw Kaczynski, whose party had introduced the legislation.
The conservative government has made it a priority to purge ex-communists and their collaborators from public life.
Reacting to the ruling, his twin brother, President Lech Kaczynski, a staunch anti-communist, said the matter was not yet closed.
It is not clear if the government will carry out its earlier threat to open up all the secret police files to the public if the court ruled against the law.
The ruling has seriously reduced the number of people who can now legally be screened.
Delivering their ruling, the judges chastised the government saying it should not seek vengeance in dealing with the country's communist past.
"The vetting law can only be applied to individuals, not collectively," said presiding judge, Justice Jerzy Stepien.
The opposition Democratic Left Alliance, mainly made up of former communists, had argued that the law violated the right to free speech.
Journalists and academics were also critical of the legislation, saying the law was itself reminiscent of communist times, when people were forced to sign loyalty pledges.