Britain’s Prime Minister David Cameron pledged on Thursday to rush through fresh measures to give police and spy agencies the power to scoop up mobile phone and internet data.

The fast-track bill follows a European Court of Justice ruling in April that said forcing data companies to keep records of phone calls, texts and internet usage violated the right to privacy and the right to protection of personal data.

Emergency legislation is critical to help law enforcement and intelligence agencies fight crime and ensure national security, Cameron said, arguing that the consequences of failing to act are grave.

“As events in Iraq and Syria demonstrate, now is not the time to be scaling back on our ability to keep our people safe,” Cameron said in a statement. “The ability to access information about communications and intercept the communications of dangerous individuals is essential to fight the threat from criminals and terrorists targeting the U.K.”

Mr. Cameron’s office said companies would start deleting the material unless they had a business reason to keep it, thus jeopardizing investigations that often unfold over a period of months. Data companies had also expressed concern about the debate on the rights of privacy versus security, and have been calling for a clearer legal framework to back cooperation with law enforcement and intelligence agencies.

The debate has intensified over the past year, following revelations from NSA systems analyst Edward Snowden that the U.S. and other countries’ intelligence agencies routinely and indiscriminately gathered and stored huge amounts of data from phone calls and Internet communications.

Mr. Cameron and his Liberal Democrat deputy Nick Clegg struck a deal on the so-called “snooper’s charter” which the junior party had earlier blocked. The coalition partners stressed that the fast-track measures represent a request to maintain existing capabilities, not to expand powers.