Firms Telekom Deutschland and SpaceNet took action in the German courts challenging the law that obliged telecoms firms to retain customers’ traffic and location data for several weeks to fight serious crime.
The case headed to the European Court of Justice (ECJ) in Luxembourg, which ruled against the German legislation.
“EU law precludes the general and indiscriminate retention of traffic and location data,” the court said in a statement, confirming its previous judgements on the issue.
The Federal Administrative Court, one of Germany’s top courts, had argued there was a limited possibility of conclusions being drawn about people’s private lives from the data, and sufficient safeguards were in place.
But the ECJ said the German legislation – which required traffic data to be retained for 10 weeks, and location for four – applies to a “very broad set” of information.
It “may allow very precise conclusions to be drawn concerning the private lives of the persons whose data are retained… and, in particular, enable a profile of those persons to be established.”
The stated aim of the law was to prosecute serious criminal offences or hinder specific risks to national security, but the court said that such measures were not permitted on a “preventative basis”.
However, it said that in cases where an EU state faces a “serious threat to national security” that is “genuine and present”, telecoms providers can be ordered to retain data.
Such an instruction must be subject to review and can only be in place for a period deemed necessary.
Following the announcement, Justice Minister Marco Buschmann hailed a “good day for civil rights”.
“We will now, swiftly and definitively, remove data retention without cause from the law,” the minister wrote on Twitter.
Data privacy is a sensitive issue in Germany, where people faced mass surveillance under the Nazi regime as well as in communist East Germany.
Buschmann is from the liberal FDP party, which has made data protection a key plank of its policies.
Interior Minister Nancy Faeser – from Chancellor Olaf Scholz’s Social Democratic Party – said she did not “want to have old debates, but act pragmatically”.
Nevertheless, she added the court ruling still gave the government space to implement “what is permissible and urgently necessary”.
Faeser noted the ruling still allowed measures such as the storing of IP addresses as part of efforts to fight crime, which she said could help in combating sexual violence against children.