Theresa May has lost a case at the European Court of Justice (ECJ) - which was brought against her by her own Brexit secretary David Davis.
On Wednesday, the ECJ ruled European Union member states cannot force internet companies to retain email data on a “general and indiscriminate” basis.
It is a victory for those opposed to the mass surveillance of people by the state.
The decision came after a legal challenge against the British government’s so called “snoopers’ charter” brought by Davis and others when he was a backbench MP.
The ruling means some parts of the Data Retention and Investigatory Powers Act (DRIPA) have been deemed unlawful.
Tom Watson, Labour’s deputy leader, who had championed the legal case alongside Davis, said the ruling showed it was wrong for the government to “arbitrarily seize” the phone records and data of citizens.
The Home Office said it was “disappointed” in the judgement.
Martha Spurrier, the director of civil liberties campaign group Liberty, said: “Today’s judgment upholds the rights of ordinary British people not to have their personal lives spied on without good reason or an independent warrant. The Government must now make urgent changes to the Investigatory Powers Act to comply with this.
“This is the first serious post-referendum test for our Government’s commitment to protecting human rights and the rule of law. The UK may have voted to leave the EU – but we didn’t vote to abandon our rights and freedoms.”
Watson said the ruling showed it was “counter-productive to rush new laws through Parliament without proper scrutiny.
“At a time when we face a real and ever-present terrorist threat, the security forces may require access to personal information none of us would normally hand over. That’s why it’s absolutely vital that proper safeguards are put in place to ensure this power is not abused, as it has been in the recent past.
“Most of us can accept that our privacy may occasionally be compromised in the interests of keeping us safe but no one would consent to giving the police or the government the power to arbitrarily seize our phone records or emails to use as they see fit. It’s for judges, not Ministers, to oversee these powers. I’m pleased the court has upheld the earlier decision of the UK courts.”