The mass collection of telecommunications data is illegal and is a violation of the EU’s charter of rights, a European court has ruled. The decision nullifies a 2006 data retention directive that was introduced to aid in the fight against terrorism.

The European Court of Justice overturned a directive that allowed telecommunications companies to collect citizens’ communications data on a massive scale and retain them for two years. The actual content of the communications was not retained, but the time and location, as well as all the necessary information to identify the user were kept.

During Tuesday’s hearing, the court said the directive contravenes the Charter of Fundamental Rights of the EU.

“The directive interferes in a particularly serious manner with the fundamental rights to respect for private life and to the protection of personal date," the Court wrote in its ruling. “It entails a wide-ranging and particularly serious interference with the fundamental rights to respect for private life and to the protection of personal data, without that interference being limited to what is strictly necessary.”

One of the main issues with the directive that the Court highlighted was the fact it allows for the retention of data without any justification. In this way, the Court concluded that the directive must be modified to minimize the impact of the privacy rights of citizens from the 28-nation bloc.

The directive was initially introduced in 2006 following bomb attacks on the public transport systems of Madrid and London. The idea was to give the authorities a greater ability to combat organized crime and terrorism across Europe.

The Court said that while the idea was commendable, “by adopting the Data Retention Directive, the EU legislature has exceeded the limits imposed by compliance with the principle of proportionality.”

Recently the European Commission proposed a revised version of the directive that set out instructions on when data may be retained and how it can be accessed and used by authorities.

The issue of data collection and retention has been at the forefront of European politics over the last year following the NSA revelations that the US organization gathers metadata on a massive scale in the EU. In addition, reports that the NSA even tapped the personal communications of top-ranking politicians sparked fury amongst many European leaders.

German Chancellor Angela Merkel even compared the US agency to the Stasi secret police following the revelations and demanded an explanation from Washington. The German government has since called for the negotiation of a “no spy” deal with Washington. However, Germany has criticized the US for its unwillingness to give assurances that it will not carry on with the same practices.

"The information we have so far is insufficient," Interior Minister Thomas de Maiziere, one of Merkel's closest cabinet allies, told German weekly magazine Der Spiegel. He added that the practices of the US were “over-the-top.”

In January of this year, President Barack Obama banned tapping the communications of other world leaders, but said the NSA would continue to gather data on the “intentions” of other governments.