Ministers must now decide whether to try to reverse the changes, which would force chief constables to seek permission from a circuit judge before carrying out surveillance operations.
If they fail, they face the prospect of being unable to push their measures through before the election.
If that happened, the police would be able to continue as they do at present, with only a oversight from security commissioners. Under these rules, they bug or watch around 1,300 vehicles, business premises or private homes each year.
The defeats came after Labour, which had originally supported the Government's proposals, changed its stance in the face of strong opposition from the legal profession.
Peers voted by 209 to 145 for a Labour amendment demanding prior authorisation and then by 158 to 137 for a Liberal Democrat measure allowing decisions to be taken by judges. Ministers had argued that the police would have to notify a security commissioner of operations but would not have to do so in advance.
Twenty-nine Conservative peers and 10 past and present law lords supporting the opposition, including the Lord Chief Justice Lord Bingham of Cornhill. Among those who spoke against the government were the former prime minister, Lord Callaghan, and a former Tory home secretary, Lord Carr of Hadley.
The Home Secretary, Michael Howard, said the measure could not remain as it stood because of contradictions in the Labour and Liberal Democrat measures. He dismissed the defeat as a "shambles" and criticised Labour for "turning turtle" at the first sign of pressure from the judiciary.
He said: "We will need to consider how we can best achieve the objective I have consistently set myself, which is to enable the police to tackle crime effectively and with proper safeguards."
Last night both Labour and the Liberal Democrats were celebrating their victory. Lord McIntosh of Haringey, Labour's home affairs spokesman in the Lords, said the measures would still allowed police enough flexibility to act quickly when necessary.
"This will provide an important safeguard in all those cases where people might reasonably expect private conversations to remain private," he said.
Lord Rodgers of Quarry Bank, for the Liberal Democrats, said the government must now make the necessary changes to its bill.
Meanwhile the Police Superintendents' Association said the development would make its members' jobs more difficult.Reuse content