The UK government has lost a key case in the European Court of Justice (ECJ) after it ruled the indiscriminate mass gathering of data on citizens is illegal.
"EU law precludes national legislation that prescribes general and indiscriminate retention of data," the court stated in its decision.
The ruling is a blow to the UK as its recently introduced Investigatory Powers Act (IP Act) will require communication firms to store all web browsing history on customers for a year.
The ruling means under EU law this is now considered illegal. However, with the UK intending to leave the EU after the Brexit referendum, the impact of the decision may be irrelevant in the long term.
At the heart of the Court's decision was the fact that, while specific data retention for matters of major criminal issues is valid, bulk and generic gathering is too broad and gives too much access to a citizens's private life.
"The Court states that, with respect to retention the retained data, taken as a whole, is liable to allow very precise conclusions to be drawn concerning the private lives of the persons whose data has been retained."
"The fact that the data is retained without the users of electronic communications services being informed of the fact is likely to cause the persons concerned to feel that their private lives are the subject of constant surveillance.
"Consequently, only the objective of fighting serious crime is capable of justifying such interference."
The ruling by the ECJ came after the UK government had referred the case to its authority, having already lost the same argument in the UK's high court.
Despite this, it intends to appeal against to the EU Court of Appeal. A Home Office spokesperson said it was necessary to challenge the decision to ensure laws like the IP Act can come into effect.
"Given the importance of communications data to preventing and detecting crime, we will ensure plans are in place so that the police and other public authorities can continue to acquire such data in a way that is consistent with EU law and our obligation to protect the public," they told the BBC.
But the Open Rights Group, which was also involved in the case, welcomed the ruling with executive director Jim Killock saying it was clear that actions by the UK government to bring in mass surveillance should now be stopped.
"The CJEU has sent a clear message to the UK Government: blanket surveillance of our communications is intrusive and unacceptable in a democracy," he said.
"The government knew this judgment was coming but Theresa May was determined to push through her snoopers' charter regardless. The Government must act quickly to re-write the IPA or be prepared to go to court again."
Meanwhile Open Intelligence think-tank co-founder Loz Kaye said: "The CJEU has kicked a massive hole in the Investigatory Powers Act. It's now open to challenge on its scope and how data is shared outside of the EU."
One interesting aspect of the case is that ls one of initial MPs to challenge the government's plans for mass surveillance was David Davis, who is now the government's Brexit minster. He has since withdrawn from the case.
Intel claims 'world first' in artificial intelligence that can be plugged-in almost anywhere
Trusts have purchased almost 385,000 new PCs since 2013, at a cost of £260 million
The council will use funds from the project to fund network expansion
Mark Vartanyan was working for Norwegian e-healthcare firm Dignio when he was arrested