Radical cleric Abu Qatada could be released from detention during the London 2012 Olympics.
Lawyers for Qatada, the man once dubbed Osama bin Laden's right-hand man in Europe, are due in the high court for a ruling on a writ of habeas corpus.
Qatada, 51, is being held in a high-security prison while he fights extradition to Jordan where he faces terrorism charges.
He will ask two judges to challenge his detention by home secretary Theresa May on the grounds that it is unlawful.
Qatada's lawyers previously claimed they had "significant evidence" that challenged a Home Office promise that evidence obtained by torture would not be used against him.
His lawyers have applied for a judicial review of the bail ruling and a writ of habeas corpus - a common law procedure developed in medieval times which effectively calls for a detained person to be brought before a court to rule if he is being unlawfully held.
Disproportionate and unlawful detention
Edward Fitzgerald QC, for Qatada, told Lord Justice Hughes and Mr Justice Silber: "Our submission is that the detention has already gone on for so long as to be disproportionate and unlawful.
"There comes a point where detention is just too long, and this is the longest period of administrative detention, so far as we know, in modern English history.
"It cannot be right, when we are already at seven years - and when there is an inevitable likelihood this it is going to go on for at least another year."
If his bid is successful could be back to the streets within a matter of days.
His last appeal to the European Court of Human Rights over his removal failed on 9 May.
The Special Immigration Appeals Commission (Siac) denied bail to Qatada ahead of a previous deportation appeal in October, saying having him on the streets during the Olympics would be "exceptionally problematic".
Qatada, also known as Omar Mahmoud Mohammed Othman, has fought deportation from the UK since 2001 at a cost to the taxpayer of nearly £1m.
He faces charges of plotting bomb attacks in Jordan in 1999 and 2000.
Mr Justice Mitting said for Siac said: "I'm satisfied that managing the risk posed by the appellant outside a category A prison during [the Olympics] would be exceptionally problematic."
A Home Office spokeswoman said: "Abu Qatada's legal team are clearly clutching at straws in their attempts to get this dangerous man released, when jail is where he belongs.
"We will strongly resist any attempt to overturn the court's decision to keep him locked up ahead of his removal from the UK.
"We agree with Justice Mitting's ruling to keep Qatada in prison and these are the last desperate attempts of a man who has run out of options."