However, the British government says it might appeal the decision, arguing that hijackers should never be rewarded, even those fleeing the Taliban.
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 repressive Taliban regime was ousted.
Their convictions were overturned on appeal and UK immigration authorities ruled in 2004 that they should be allowed to stay in Britain as refugees rather than deported - a decision which the government deliberately failed to implement, the High Court judge found.
"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 UK.
Prime Minister Tony Blair criticised the judge's decision. "We can't have a situation in which people who hijack a plane we are not able to deport back to their country," Mr Blair said outside his Downing Street residence.
"It is not an abuse of justice for us to order their deportation. It is an abuse of commonsense, frankly, to be in a position where we can't do this."
Appeal expected
Mr Blair said that the hoped the government would be able to appeal against the judgment. Discretionary leave allows the men and their families, whose applications for asylum have been rejected, to work and apply for benefits in Britain. The Home Office can review their status every six months, though the leave becomes indefinite after five years.
The men hijacked the Ariana Airlines jetliner with 188 people aboard 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, north-east of London.
Testimony during the original trial said that the men had been armed with guns and grenades and had threatened to kill passengers and crew members.
After their convictions were overturned, immigration authorities found that sending them back to Afghanistan would violate their human rights by exposing them to possible attack by members of the Taliban.
Justice Sullivan has now ordered the British Home Office to pay legal costs to show his "disquiet and concern" at their handling of the case.
