The government's plans to extend terror detention limits to 42 days have been heavily defeated in the House of Lords.
Peers voted to keep the current 28-day limit on pre-charge detentions by 309 votes to 118 - a majority of 191.
Later the home secretary said it would be dropped from the counter-terrorism bill but would be in a new bill to be made law "should the worst happen".
Among those voting against the government were former lord chancellors Lord Falconer and Lord Irvine.
Last week ministers said the plan would return to MPs if defeated but there had been speculation it might be dropped.
BBC political correspondent Iain Watson said Monday's result was a much bigger defeat than had been expected.
Shadow security minister Baroness Neville-Jones, who had described the 42-day plan as "unworkable" and "constitutionally worrying", told the BBC later there had been "very heavy abstentions on the government benches".
"This has been a very big majority against," she said.
"It must make it very difficult for the government to proceed with this piece of legislation and send it back to the Commons as if nothing had happened."
Crossbencher Lord Dear, a former chief constable who tabled the amendment to keep the pre-charge detention limit at 28 days, called ministers' plan "fatally flawed".
Opening the debate, he said: "This attempt to appear tough on terrorism, I believe, is a shabby charade which is unworthy of a democratic process and we should reject it."
He said there was "no proven case" for changing the limit, that the legislation was "fatally flawed, ill thought-through and unnecessary" and would "further erode fundamental and legal rights that have been the pride of this country for centuries".
Supporting Lord Dear's amendment were Baroness Neville-Jones, Lib Dem frontbencher Lord Thomas and Labour QC Baroness Mallalieu.
But Security Minister Lord West had warned peers: "If it is rejected and the government is right... it could mean dangerous terrorists are released to commit atrocities."
He said: "As a government, we often face the issue that we are all wrestling with in this House, balancing the safety of the majority of our population against the freedom of the individual and I am certain where our duty lies."
This is not the end of civil liberties as we know it. And it could have a consequence of saving many lives at home and abroad
And Lib Dem peer Lord Carlile, the official reviewer of terror laws, said he did not want to have to make changes to the law in the aftermath of a major terrorist attack.
"I see no thin end of the wedge argument here. What I see is finality in the law of detention with appropriate detention," he said.
He said he believed the extension would affect adversely a "maximum maybe of five or six people in the next four or five years".
"This is not the end of civil liberties as we know it. And it could have a consequence of saving many lives at home and abroad."
Several peers did not vote along party lines. Former lord chancellor Lord Falconer said he would vote against the government "with a heavy heart", while the former Conservative chairman Lord Tebbit said he would vote with the government.
Lord Tebbit warned his own party they may "rue this day" if they won the next general election and found they needed the powers.
Among those voting to support the amendment to keep the limit at 28 days were former education secretary Baroness Morris, former MI5 head Baroness Manningham-Buller, former Lord Chief Justice Lord Woolf and former Metropolitan Police Commissioner Lord Condon.
The government failed in 2006 to extend pre-charge terror detention to a maximum of 90 days. Instead, the current 28-day limit was agreed as a compromise.
Ministers could use the Parliament Act to force the 42-day proposal into legislation.
But BBC political editor Nick Robinson reported last week that the government had decided against this, as it would be time-consuming and controversial.
During Monday's debate police had to lock the doors to Parliament after airport protesters tried to force their way into the Palace of Westminster.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.