A sweeping new surveillance regime is set to become UK law before the end of the year after the Investigatory Powers Bill passed through the House of Lords on Wednesday.

The legislation, dubbed the ‘snooper’s charter,’ creates a legal framework authorizing the government to hack into devices, networks and services in bulk.

Read more

The law will allow for large databases of personal information on UK citizens to be maintained.

It requires internet, phone and communication app companies to store records for 12 months and allow authorities to access them on demand. That data could be anything from internet search history, calls made or messages sent.

Security agencies will also be able to force companies to decrypt data, effectively placing limits on the use of end-to-end encryption.

For the bill to become law it still requires royal assent, which is essentially a formality. Once this is done, the UK will have one of the most wide-ranging, all-encompassing and privacy-invading mass surveillance programs in the world, according to critics.

Prime Minister Theresa May pushed hard for the bill on the basis of counter-terrorism.

The government argues the incoming law provides intelligence and law enforcement agencies with the powers necessary to fight terrorism and investigate crime.

The UK has just legalized the most extreme surveillance in the history of western democracy. It goes farther than many autocracies. https://t.co/yvmv8CoHrj — Edward Snowden (@Snowden) 17 November 2016

The legislation has been divisive since first published. Many interested parties, from communications service providers to tech companies, have spoken negatively of a number of proposals.

The #ipbill has passed both Houses of Parliament. Soon, a record will be kept of every website you ever go to. That should worry you. — Julian Huppert (@julianhuppert) November 16, 2016

That's it, the #IPBill has gone thru and will soon be an Act. We've given our security services unprecedented powers to spy on us. — Jenny Jones (@GreenJennyJones) November 16, 2016

Joanna Cherry, a Scottish National Party (SNP) MP, says Britain has gone “further than any other Western democracy” in its expansion of surveillance powers and its ability to collect bulk data without justifiable reason.

“At least the IP Bill is honest about the fact that it permits the collection of bulk data. However, we shouldn’t be too congratulatory of the bill as we have now gone further than any other Western democracy,” she said in August.

Organizations such as Big Brother Watch and Privacy International have been in staunch opposition of the legislation, arguing it will allow for fundamental breaches of privacy and human rights.

The Investigatory Powers Bill replaces the Regulation of Investigatory Powers Act.