Sohel Chowdury, of Bangla-desh, was seeking a writ of habeas corpus to secure his freedom, but the Home Office sought to delay a decision pending a Court of Appeal judgment on a test case in which a High Court judge had ruled that some asylum seekers were being held illegally because immigration officers had no power to interrogate, detain or deport them while their applications were being considered.
However, when Mr Justice Dyson, who was presiding in both cases, indicated that he was minded to grant Mr Chowdury's freedom, Home Office lawyers offered a compromise - to allow him out on bail.
Mr Justice Dyson's earlier ruling two weeks ago has thrown immigration policy into chaos and could lead to massive compensation claims.
About 570 asylum seekers, many of whom claim to have been tortured and persecuted, are being held in detention centres or jails. Their detention, which can last for months without any right of appeal to a court, has attracted widespread criticism from refugee groups.
The powers were designed to deal with illegal immigrants - whom it was envisaged would only be held for up to two days, until they could be deported - not asylum seekers.
It is estimated that the ruling, on its narrowest interpretation, could lead to 97 detainees being freed straight away. Lawyers are expected to use the judgment to argue for other categories of asylum seekers.
The Home Office, fearful of its effects on enforcement of its policy on illegal immigrants, is contesting the ruling. Because of the importance of the case, the Court of Appeal is expected to rule next week. But the issue is almost certain to be decided by the House of Lords.
After the decision on Mr Chowdury's case, Richard Dunstan, refugee officer for the human rights organisation Amnesty International, said: "The Home Office should now consider bail for all the other detainees covered by the ruling.
``Otherwise their freedom becomes arbitrary - down to whether or not they have a lawyer who knows about the ruling and who can make an application to the courts."
In another case, the Home Office was accused of deliberately seeking to defeat the purpose of the court ruling by reaching a sudden decision on the asylum application, turning it down.
Amnesty said it knew of at least three other habeas corpus cases this week, which had been similarly prematurely ended - an allegation that was strongly denied by the Home Office, which said each case was decided on its merits.Reuse content