Media playback is unsupported on your device Media caption Nick Robinson explains on Daily Politics why there is a rush to bring in the new law

Emergency legislation will be brought in next week to force phone and internet companies to log records of customer calls, texts and internet use.

Ministers say it is necessary so police and security services can access the data they need after a legal ruling which declared existing powers invalid.

The proposed law has the backing of Labour and the coalition parties.

A special cabinet is being held to agree the planned laws, which will only last until 2016.

Prime Minister David Cameron and his Lib Dem Deputy Prime Minister Nick Clegg will tell a special cabinet meeting on Thursday that emergency legislation is necessary to keep the country safe.

A recent ruling of the European Court of Justice has removed the obligation on telecoms companies to retain records of when and who their customers have called, texted and emailed.

Without a new law Mr Cameron and Mr Clegg will claim that that information could be destroyed within weeks by companies fearing legal challenges.

Labour is backing emergency legislation after all-party talks agreed that this law would enshrine existing rights and not be used to extend them by re-introducing the so-called "snoopers charter".

It will also bring in so-called safeguards including:

The creation of a new Privacy and Civil Liberties Oversight Board to examine the impact of the law on privacy and civil liberties

A review of the controversial RIPA - Regulation of Investigatory Powers Act

Annual government transparency reports on how these powers are used

The law will include a so-called sunset clause - ensuring that these powers will die in 2016 - so there will be a longer and wider debate about what replaces them.

Critics will no doubt argue that the time for that debate is now. To pass any new law in just a week is rare. So too is it to have the backing of all three main parties even before it is published.

On a subject as sensitive as giving the police and security services access to phone and internet data this is bound to be controversial.

Update 08:45 BST: The emergency legislation will oblige telecom firms to retain data for 12 months. Under the European law which it replaces companies could be asked to retain data for 24 months.

More controversially the new law will also produce what is being described as a "clearer legal framework" to allow access to the content of calls, texts and emails after a warrant is signed by a senior government minister. Telecoms companies are said to have warned ministers that after the Edward Snowden revelations they are vulnerable to legal challenge by their customers.

The Labour MP Tom Watson has condemned the plans as a "stitch up" which prevent MPs from considering the legislation properly.