Secret evidence that might have been obtained by torture cannot be used against terror suspects in UK courts, the law lords have ruled.
An anti-torture protester in London earlier this year
The decision means the cases of eight detainees facing deportation are expected to be reconsidered by the Special Immigration Appeals Commission.
It is a victory for eight men who had been held without charge.
Home Secretary Charles Clarke accepted the ruling but said it would have "no bearing" on efforts to combat terror.
He said the government did not use evidence it knew or suspected had been obtained by torture but the ruling had clarified the appropriate legal test of what was admissible.
Home Office minister Tony McNulty later admitted to Channel 4 news that the government could only establish "as far as we possibly can" that evidence had not been gathered under torture.
Thursday's ruling centres on how far the government must go to show improper methods if obtaining information from suspects have not been used.
The Court of Appeal ruled last year that such evidence could be used if UK authorities had no involvement.
But eight of the 10 foreign terror suspects who were being held without charge, backed by human rights groups, challenged that ruling.
They argued evidence obtained in US detention camps should be excluded from court hearings.
It is thought some of the eight men are being held in Belmarsh or other high security prisons, pending deportation, some released on bail and others restricted by the government's new control orders. The Home Office will not confirm precise figures.
The Special Immigration Appeals Commission (SIAC) must now investigate whether evidence against the suspects facing deportation was obtained by torture.
One of the detainees involved in the ruling, Jamel Ajouaou, told BBC News he was grateful to the law lords.
Mr Ajouaou left Britain in December 2001 of his own accord and went home to Morocco.
He said: "It is actually victory. It is not for the detainees. It is for the British people because a great country such as Britain deserves a better law than the law of the jungle."
The home secretary said the government had not been planning to rely on evidence it knew or suspected had been obtained under torture.
Nor did he expect the ruling to affect the outcome of the men's appeals.
Mr Clarke said: "We have always made clear that we do not intend to rely on or present evidence in SIAC, which we know or believe to have been obtained by torture. So this issue is hypothetical."
Lord Bingham, the former Lord Chief Justice, who headed the panel of seven law lords, said English law had abhorred "torture and its fruits" for more than 500 years.
"I am startled, even a little dismayed, at the suggestion (and the acceptance by the Court of Appeal majority) that this deeply-rooted tradition and an international obligation solemnly and explicitly undertaken can be overridden by a statute and a procedural rule which make no mention of torture at all," he said.
Another member of the panel, Lord Carswell, said allowing evidence from torture to be used would "involve the state in moral defilement".
Lord Carlile, the independent reviewer of the government's terrorism laws, said the ruling reaffirmed the law as most lawyers had assumed it to be.
Evidence in a small number of cases would now be re-examined, he said.
Conservative shadow attorney general Dominic Grieve said the judgement was "a completely correct restatement of a law that has existed for hundreds of years".
And Lib Dem foreign affairs spokesman Sir Menzies Campbell said the "landmark judgement" showed judges had "once again been more effective in defending individual rights than this government".
Amnesty International said the "momentous" ruling overturned the "tacit belief that torture can be condoned under certain circumstances".
The former British ambassador to Uzbekistan, Craig Murray, said it was untrue the UK Government did not use information from torture.
He had been told the UK did not use torture itself or ask that any specific person be tortured.
"As long as we kept within that guideline, then if the Uzbeks or the Syrians, or the Egyptians or anyone else tortured someone and gave us the information that was OK," said Mr Murray.