The so-called Snoopers' Charter has been ruled "unlawful" by the High Court in London following a legal challenge brought by Labour MP Tom Watson.
Watson, represented by human rights campaign group Liberty, launched a legal challenge against the Data Retention and Investigatory Powers Act (DRIPA) back in 2014 - the latest in a string of surveillance laws governments of all colours have sought to implement for the past decade or more.
Watson had argued that the Act, which was rushed through parliament, breached British people's rights and was "incompatible" with both the European Convention on Human Rights and the EU Charter of Fundamental Rights.
The challenge had cross-party support from Conservative MP David Davis, who dropped out following his appointment as Brexit secretary in 2016.
"The Data Retention and Investigatory Powers Act does not answer the concerns of many that the blanket retention of personal data is a breach of fundamental rights to privacy," he said at the time.
On Tuesday, Liberty announced that the Court of Appeals has sided with the challenge, ruling that, that DRIPA broke the law and breached British people's rights. By extension, therefore, the later Investigatory Powers Act 2016 is also likely to be ruled illegal.
Judges said that the law "did not restrict access to this data, in the context of the investigation and prosecution of crime, to the purpose of fighting serious crime, and "let police and public bodies authorise their own access, instead of subjecting access requests to prior authorisation by a court or independent body".
Liberty claims that the ruling means that significant parts of the Investigatory Powers Act 2016, better known as the 'Snoopers' Charter', are effectively unlawful and must be urgently changed.
Half-baked plans... do not even fully comply with past court rulings requiring mandatory safeguards
While the government has already put some safeguards in place in anticipation of Tuesday's ruling, Liberty has slammed the "half-baked plans" that "do not even fully comply with past court rulings requiring mandatory safeguards".
Liberty director Martha Spurrier said: "The government must now bring forward changes to the Investigatory Powers Act to ensure that hundreds of thousands of people, many of whom are innocent victims or witnesses to crime, are protected by a system of independent approval for access to communications data."
Watson is also calling for the government to act. He said: "This legislation was flawed from the start. It was rushed through Parliament just before recess without proper parliamentary scrutiny.
"The government must now bring forward changes to the Investigatory Powers Act to ensure that hundreds of thousands of people, many of whom are innocent victims or witnesses to crime, are protected by a system of independent approval for access to communications data."
Liberty, separately, is challenging the so-called Snoopers' Charter in a case that will go to the High Court later this year.
Manufacturing and finance jobs will be hit, but health and education can look forward to job creation, says PwC
US startups plan to modify existing jet engines, but are likely to fall foul of environmental legislation
The Brexit white paper "gets pretty close" to company desires, but there's still work to do
Children as young as four to be taught about the dangers of social media