Image copyright PA Image caption The government says the new law will maintain existing powers

Emergency legislation enabling the police to continue to be able to access communications companies' records of phone and internet use has cleared Parliament and is set to become law.

Peers approved the Data Retention and Investigatory Powers Bill after two consecutive days of debate.

It had already won MPs' backing.

Ministers said it needed to be rushed through to maintain the state's existing powers, after a European Court of Justice ruling in April.

But critics had demanded more time to debate the measures.

Internet entrepreneur and independent crossbench peer Baroness Lane-Fox had said: "It makes me very nervous that bills that require such technical expertise are given so little time."

And Lord Butler of Brockwell, the former head of the civil service, said it "beggars belief" that the government could not have introduced the bill weeks ago.

But Home Secretary Theresa May had said: "If we delay we face the appalling prospect police operations will go dark, that trails will go cold, that terrorist plots will go undetected.

"If that happens, innocent lives may be lost."

Labour supported the bill, but criticised the timetable for its passage through Parliament.

The opposition also urged that the Interception of Communications Commissioner should be required to report every six months on how the new law is working and whether it genuinely has not conferred more powers on the security services - a request that the government agreed to.