The men were initially jailed in Britain for the bloodless hijacking of an Afghan Boeing 727 in February 2000, nearly two years before Afghanistan's Taliban government was ousted.
Their convictions were overturned on appeal and immigration authorities ruled in 2004 that they should be allowed to stay in Britain as refugees rather than deported, a decision that the government deliberately failed to implement, a High Court judge ruled on Wednesday.
"It is difficult to conceive of a clearer case of conspicuous unfairness amounting to an abuse of power," Justice Jeremy Sullivan said, ordering the government to grant the men and their families discretionary leave to stay in the country.
Sullivan ordered the British interior ministry on Wednesday to pay legal costs, to show his "disquiet and concern" at their handling of the case.
But Tony Blair, the British prime minister, criticised the judge's decision and said he hoped the government would be able to appeal against the judgment, arguing that hijackers should never be rewarded, even those fleeing the Taliban.
Blair: Hijackers should never
"We can't have a situation in which people who hijack a plane we are not able to deport back to their country," Blair said.
"It is not an abuse of justice for us to order their deportation. It is an abuse of common sense, frankly, to be in a position where we can't do this."
Discretionary leave allows the men and their families, whose applications for asylum have been rejected, to work and apply for benefits in Britain.
The interior ministry can review their status every six months, although the leave becomes indefinite after five years.
The men hijacked the Ariana Airlines jetliner with 188 people on board during a flight from Kabul to Mazar-e-Sharif in northern Afghanistan.
They forced the crew to fly to Britain and surrendered after a four-day standoff with police at Stansted Airport, northeast of London.