Home Secretary Theresa May has lost her appeal against a ruling preventing the deportation of preacher Abu Qatada.
She acted after the Special Immigration Appeals Commission said the radical cleric could not be returned to Jordan.
Judges say he could face an unfair trial involving evidence obtained by torturing others.
The Home Office said it would further appeal, adding: "This is not the end of the road. The government remains determined to deport Abu Qatada."
A spokesman added: "In the meantime we continue to work with the Jordanians to address the outstanding legal issues preventing deportation."
In their judgement, Lord Dyson, sitting with Lord Justice Richards and Lord Justice Elias, said the appeals commission was entitled to think there was a risk the "impugned statements" would be admitted in evidence at a retrial. This meant there was "a real risk of a flagrant denial of justice".
The judges said the court accepted that Qatada "is regarded as a very dangerous person", but that was not "a relevant consideration" under human rights laws.
Immigration legislation
Abu Qatada's legal team has not yet lodged a bail application with the Special Immigration Appeals Commission.
Judges would not be able to hear any application before the Easter break which means he remains in prison for the time being.
Continue reading the main story
This law can only be used to hold someone if there is a realistic prospect the person is going to be deported - a prospect this ruling undermines.
Abu Qatada was re-arrested and returned to Belmarsh prison earlier this month following an alleged breach of bail conditions, concerning the use of communications equipment at his home.
The Metropolitan Police said his breach was linked to an investigation into extremist internet material.
If the police arrested and charged him with an offence in relation to that investigation, or another accusation, they could ask a judge to remand him in prison before trial.
Abu Qatada has never been charged with an offence in the UK.
Shadow home secretary Yvette Cooper said: "This is an extremely serious and disappointing judgment which rips apart Theresa May's strategy for deporting Abu Qatada and contradicts her repeated assurances to Parliament that her approach would get him swiftly on to a plane.
"The home secretary needs to pursue all legal avenues, demonstrate further work with Jordan, take urgent action to keep the public safe, and get this deportation back on track."
Siac ruled in November there was a "real risk" evidence gained by torture could be used against Abu Qatada at a retrial in Jordan, meaning that he would not get a fair hearing.
In April 1999, he was convicted in his absence on terror charges in Jordan and sentenced to life imprisonment, and it is on these charges that he faces a retrial.
'Compelling evidence'
At a Court of Appeal hearing earlier this month, lawyers for the UK government argued a block on his deportation should be lifted, saying a "fair" trial in Jordan was possible.James Eadie QC, appearing for Mrs May, said Siac had taken an "erroneous" view of the situation in Jordan and the legal tests that had to be applied when it came to assessing the conditions Abu Qatada could face there.
He said Jordanian law bans the use of torture and reliance on statements extracted under duress.
Jordanians will do everything in their power to make sure Abu Qatada receives a trial that was "fair and seen to be so", he added.
But lawyers for Abu Qatada told the court that the UK should not send someone back to a country with a "dubious human rights record".
Edward Fitzgerald QC, appearing for the cleric, argued the Siac ruling was right and there was "concrete and compelling evidence" that his co-defendants were tortured into providing evidence.
He said government lawyers had "identified no error of law" and were "quarrelling with findings of fact".
Abu Qatada was first arrested in October 2002 in south London and detained in Belmarsh high-security prison. He was re-arrested and released on bail number of times over the years that followed.
In November 2012, he was released on bail from prison in when the courts blocked the home secretary's latest attempt to deport him to Jordan.