The Karlsruhe-based Constitutional Court ruled that the mass storage of private records breaches Germany's constitution, effectively overturning a law passed in 2008 that compels communications companies to keep tabs on customer phone and internet usage for six months.
The court also demanded that data already stored be deleted ''immediately,'' according to the website of news magazine Der Spiegel.
The ruling is a blow to supporters of tougher measures to fight terrorism and other crimes.
The court has essentially decided the law did not meet the principle of proportionality – that is, the law's erosion of personal privacy outweighed its usefulness in combating terrorism.
The panel of judges ruled that the storage of the data was not sufficiently secure and that the law did not properly define how the information could be used. The judges also criticised the transparency of the law.
Introduced in 2008 under the previous "grand coalition" government, the legislation forced telecommunications firms to store customers' phone, email and internet records, including the location of mobile phone calls, for six months.
The data could then be used for criminal proceedings, including investigations and prosecutions of suspected terrorists.
In Germany's largest class action, some 35,000 people went to the court to fight the law, including the country's current Justice Minister Sabine Leutheusser-Schnarrenberger, of the pro-business liberal Free Democrats (FDP).
Importantly, the court did not forbid the storage of data altogether but rather criticised the specific legislation. Therefore, it did not challenge the 2006 EU directive that was the basis for the German law.
The law constituted “a particularly heavy intrusion with a scope such as the legal system has not thus far known,” the ruling stated.
Such legislation had to be subject to very strict terms – a criterion the present law failed to meet, the court said.
Ahead of the ruling, the conservative Christian Democratic parliamentary expert on interior affairs, Wolfgang Bosbach, warned that overturning the law would hamper essential investigations into crimes including child pornography.
“If the law is strictly limited, we will no longer be able to prevent and clear up many crimes,” he said, adding there had been no instances so far where the law had been abused.