The bill has suffered two defeats in the Lords
The government has suffered a defeat in the Lords where peers have backed plans for an independent commissioner for terrorist suspects.
It is the second defeat in the Lords on the Coroners and Justice Bill in less than a week.
Peers, led by retired law lord Lord Lloyd, demanded the post be created and won by 145 votes to 103, majority 42.
For the government Lord Brett warned it could delay police inquiries and was an unnecessary addition to safeguards.
Lord Lloyd, who reviewed terrorism laws for the last Conservative government under John Major, said the commissioner would act as "the eyes and ears of the judge" when prosecutors applied to extend pre-charge detention of a suspect.
The current limit for holding a terrorism suspect without charge is 28 days and has proved contentious.
Attempts to extend it to 90 days in 2005 ended in Tony Blair's first Commons defeat as prime minister.
Last year the government again tried to extend it, this time to 42 days and narrowly won a Commons vote. But it was abandoned months later after it was overwhelmingly rejected in the Lords.
Lord Lloyd argued that having a commissioner would reassure the Muslim community, not only that suspects were being well treated but that the police were getting on with the investigation as quickly as they could.
"The community needs to be reassured that suspects are not being detained for a day longer than is absolutely necessary," he said.
The commissioner would have access to secret evidence that could not be disclosed to the suspect or his lawyer and could help the judge decide whether or not to extend detention.
The amendment was backed by Conservative and Liberal Democrat peers and some crossbenchers.
Among them was former chief inspector of constabulary Lord Dear, who said: "I believe, on balance, that the greater good that may be achieved by the creation of the commissioner post far outweighs any potential disadvantage."
Lord Lloyd's amendment was accepted in principle by Home Office minister Lord West of Spithead when he first raised it last November.
But on Monday ministers argued that there would need to be more than one commissioner to cover the whole of the UK and that the scheme would cost far more than Lord Lloyd had suggested.
Last week the government was defeated on another part of the wide ranging Coroners and Justice Bill when it tried to remove a clause allowing free speech to be used as a legitimate defence in laws against inciting homophobic hatred.