The European Union's highest court on Tuesday overthrew a rule that required telecommunications companies to store the communications data of EU citizens for up to two years, on the grounds that it infringed on basic rights.
Brussels introduced the data-retention directive in March 2006 after bombings on public transport in Madrid and London. The aim was to give the authorities better tools to investigate and prosecute organised crime and terrorism.
But not all countries - including Germany, where privacy is an especially sensitive issue - have implemented the directive. They could have faced penalties if the court had upheld the rule requiring companies to store data from six months to two years.
The court ruled that the directive "exceeded the limits" of proportionality.
"The court takes the view that, by requiring the retention of those data and by allowing the competent national authorities to access those data, the directive interferes in a particularly serious manner with the fundamental rights to respect for private life and to the protection of personal data," it said.
"Furthermore, the fact that data are retained and subsequently used without the subscriber or registered user being informed is likely to generate in the persons concerned a feeling that their private lives are the subject of constant surveillance," the court added in a statement.
The rule had required telecoms service providers to keep traffic and location data as well as other information needed to identify the user, but not the content of the communication.
In Germany, the directive caused a public debate. Germany's Constitutional Court blocked a law in 2010 to store all data for six months. The government has said it would present a new law.
The topic is sensitive in Germany because of the surveillance by the Gestapo in the Nazi era and by communist East Germany's Stasi secret police. Germans were outraged by reports last year of large-scale spying on German and European citizens, institutions and politicians by US intelligence agencies.
In the four-month-old "grand coalition" between Merkel's conservatives and the Social Democrats (SPDR), the timing rather than content of the law was one of the early dividing issues.
Having pushed for the coalition treaty to include a promise to pass a data-retention law quickly, SPDR Justice Minister Helio Maas then said in January he would wait until the European judges had issued their ruling.
After the verdict, Maas said Germany no longer faced fines and could take time to draw up a new law. But the conservative Interior Minister Thomas de Maiziere urged swift legislation and said data retention of three to six months should be possible.
Austrian and Irish courts had asked the European Court of Justice to rule if the law was in line with the Charter of Fundamental Rights of the EU.