Emergency laws will be introduced next week to force service providers to log records of calls, texts and internet use for 12 months.
The measures are in response to a European Court of Justice (ECJ) ruling in April which abolished regulations that enable telecoms companies to retain data for up to a year for police use.
The Prime Minister David Cameron said the fast-track measures are necessary to defend national security against threats of terrorism.
Providers would be forced to delete information within weeks after the ECJ ruled that keeping records who customers had called, texted and emailed for 12 months amounts to an invasion of privacy.
The emergency Data Retention and Investigation Powers Bill has support from the coalition parties and Labour and was approved in a special Cabinet meeting. It will contain a sunset clause, meaning it will be reviewed in 2016. Cameron joined his deputy Nick Clegg in a joint press conference to announce the measures.
Mr Cameron said: “It is the first duty of government to protect our national security and to act quickly when that security is compromised. As events in Iraq and Syria demonstrate, now is not the time to be scaling back our ability to keep our people safe.
“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 UK.”
Though the opposition do support the measures, the government has been criticised for fast tracking the legislation. Labour MP Tom Watson said he would vote against some aspects of the measure and criticised the government for waiting until the dying days of Parliament to railroad them through, despite knowing about the ECJ ruling weeks ago.
The Prime Minister defended the decision to introduce the law quickly, saying: “No government introduces fast track legislation lightly but the consequences of not acting are grave.
“This is about restoring two vital measures ensuring that our law enforcement and intelligence agencies maintain the right tools to keep us all safe.”