MPs have voted through the government's emergency legislation giving the security services access to people's phone and internet records.

Some MPs criticised the government's timetabling of the Data Retention and Investigatory Powers Bill, which completed its passage through the lower chamber in one day.

Conservative MP David Davis said the timetable was "entirely improper".

But MPs approved both the timetable and the bill itself in separate votes.

It passed its final stage in the Commons at 22:00 BST, and is now expected to move on to the House of Lords on Wednesday.

A bill's passage through the Commons usually takes a matter of weeks or months, although there are well-established procedures for fast-tracking bills when MPs believe that it is necessary to do so.

'Democratic banditry'

The plans are supported by the three main parties, but opposed by civil liberties campaigners.

They were drafted in response to a European Court of Justice ruling in April.

Image caption Theresa May said "innocent lives may be lost" if MPs did not pass the bill

Home Secretary Theresa May said: "This bill merely preserves the status quo. It does not extend or create any new powers, rights to access or obligations on communications companies that go beyond those that already exist.

"It does not address the same problems or replicate the draft communications data bill published in 2012.

"We do still face a decline in our ability to obtain the communications data we need caused by the use of modern technology... but that is not what we are considering today.

"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."

But she said the government would accept a Labour proposal for reports every six months by the Interception of Communications Commissioner on how the new law is working.

Image caption Yvette Cooper said the bill was needed to "fight crime and keep our country safe"

Labour shadow home secretary Yvette Cooper told the Commons that her party would support the "sticking plaster" bill but called for a much wider debate on the balance between safety and civil liberties.

She said: "This is not the way that this kind of legislation should be done. Let's be clear, the last-minute nature of it does undermine trust in the government's intentions but also in the vital work the police and agencies need to do.

"But I also have no doubt this legislation is needed and that we cannot delay it until the autumn.

"Parliament does need to act this week so that existing investigations and capabilities are not jeopardised over the next few months."

Image caption David Davis said the timetable undermined MPs' ability to "defend the freedom and liberty of our constituents"

Mr Davis, a former contender for the leadership of the Conservative Party, blamed disagreements between his party and the Liberal Democrats for the delayed response to the ruling.

"My understanding is there was an argument inside government between the two halves of the coalition and that argument has gone on for three months. So what the coalition cannot decide in three months this House has to decide in one day.

"This seems to me entirely improper because of the role of Parliament - we have three roles.

"One is to scrutinise legislation, one is to prevent unintended consequences, and one is to defend the freedom and liberty of our constituents.

"This undermines all three and we should oppose this motion."

Labour MPs also criticised the government for attempting to rush through the laws, with former election campaign chief Tom Watson describing it as an "insult" and likening it to "democratic banditry resonant of a rogue state".

Image caption David Winnick also suggested the timetable was impossible to justify

Veteran Labour MP David Winnick, a member of the Home Affairs Select Committee, said: "I consider this to be an outright abuse of parliamentary procedure.

"Even if one is in favour of what the home secretary intends to do, to do so in the manner in which it is intended, to pass all stages in one go, surely makes a farce of our responsibilities as MPs.

"When one considers the issues involved, how can one justify saying in effect that every stage of this bill must go through by 10pm?"

But former Labour home secretary Jack Straw said he would give Mrs May the "benefit of the doubt" over the legislation and told MPs: "I've been in the position of having to bring forward emergency legislation. It is never easy.

"I have often thought there is an inverse relationship between the extravagance of language used and the strength or otherwise of the argument made.

"No case has been made as to why this legislation should not be dealt with today, nor arguments in all the briefings we have had that suggest, for a second, substantively why and how this legislation goes beyond what everybody assumed to be the state of the law before the European Court of Justice judgement."

'Antidote to paedophilia'

Unveiling the measures last week in a joint news conference with Deputy Prime Minister Nick Clegg, Prime Minister David Cameron said it was about maintaining existing capabilities - not introducing new "snooping" laws.

Media playback is unsupported on your device Media caption Shami Chakrabarti, of Liberty, says "Parliament is being shown contempt"

The government said it was forced to act after the European court struck down an EU directive in April requiring phone and internet companies to retain communications data on the grounds that it infringed human rights.

A deal to rush through the measures was agreed by Mr Cameron, Mr Clegg and Labour leader Ed Miliband last week.

But campaign group Liberty said it was about "snooping on everyone".

Shami Chakrabarti, its director, also criticised the lack of scrutiny of the bill, saying "Parliament is being shown contempt".

She added: "I appreciate that this data can be vital in serious criminal investigations, but what's been going on increasingly is that because it's possible to capture more and more of everybody's data, the government is building a bigger and bigger haystack.

"It's disproportionate and Parliament should have had more than three days to look at such an important issue."

In a letter to Mr Milband, Mr Watson wrote of his "huge personal disappointment" at Labour's backing of the measures.

He added: "Far from scrutinising the Data Retention and Investigatory Powers Bill, we seem to have helped generate the panic needed to rush this important bill through under controversial emergency procedures, and the myth needed to present it as the antidote to paedophilia."

The government won a large majority of 387 on its proposed Commons timetable for the legislation, as MPs agreed by 436 votes to 49 to complete consideration of the bill in one day.

MPs subsequently approved the general principles of the bill at second reading by 498 votes to 31, a government majority of 467. It later passed its third and final reading by a comparable margin of 416 votes.