An Afghan judge who has been forced to go into hiding from the Taliban was wrongly refused relocation to the UK, the High Court has ruled.
The anonymous claimant prosecuted Taliban and Islamic State group members, and has since avoided an assassination attempt, the court heard.
The UK government argued he had not worked closely enough with the UK in Afghanistan to qualify for relocation.
A UK government spokesperson says officials are "considering" the ruling.
The Afghan judge is currently in hiding in an unspecified third country with his wife and children, two of whom are in poor health, it emerged in court.
He lives with the constant "risk that they may be forcibly returned to Afghanistan", according to a ruling in his favour.
Zoe Cooley, the claimant's solicitor, said the government had a "moral, as well as a legal, responsibility to bring our client and his family to safety".
The ruling does not automatically qualify him for relocation but does mean the government must now reassess his application in light of the court's findings.
Ms Cooley called on the UK government to act "very swiftly" to bring the judge and his family to the UK before it was "too late".
'Plainly faulty'
The Afghan Relocations and Assistance Policy (ARAP) scheme was set up to offer people who worked for or with the UK government in Afghanistan a path to move to the UK.
It is aimed at those who could be exposed to retribution by the Taliban, which re-seized power in Afghanistan in August 2021, due to their association with international forces involved in the invasion.
The Afghan judge who brought the High Court case first applied to ARAP in August 2021 but was rejected in March 2022 - a decision upheld by an appeals panel in May 2023.
The government officials responsible for reviewing the application effectively ruled that he did not directly work for or with the UK government and was therefore not eligible.
Now High Court judge Mr Justice Julian Knowles has ruled that decision was "irrational" and based on "plainly faulty" reasoning as the Afghan judge's activities "personally and directly" had helped to further the UK's goals in Afghanistan.
'Assassinations and terror'
The High Court heard the judge asked for help to leave Afghanistan during the August 2021 evacuation but "did not receive a reply" and was left in the country.
He served as a senior judge for six years in an area which saw some of the heaviest fighting and counter-insurgency during the Afghanistan war.
The court heard he oversaw cases involving murder, violence against women, terrorism, kidnapping, drug smuggling and corruption.
The perpetrators were often members of the Taliban and the Islamic State group.
When the Taliban had surrounded his home city in 2021 during its rapid campaign to seize control of Afghanistan, the judge had to be "air-lifted out of the region by military aircraft" for his safety, the High Court was told.
Mr Justice Knowles accepted the claimant's evidence that the Taliban had had informants on the court's staff during his time as a judge - some of whom now hold high-ranking positions in the government.
Some of the people the judge sentenced in Afghanistan have since "obtained high positions in the present Taliban regime".
The judge was involved in cases where suspects were apprehended after operations based on intelligence provided by "international forces" operating in Afghanistan.
•Female Afghan judges hunted by the murderers they convicted
Special forces blocked UK resettlement applications from elite Afghan troops
MoD fined after email blunder risked Afghan interpreters' lives
Taliban operatives have "visited family members seeking [the] whereabouts" of the judge, the court heard.
A partial statement from the judge was published by the court on Monday as part of the ruling. It read: "I am struggling a lot and my wife and children now have a very hard life. What we are going through is very difficult.
"The situation here is much worse than the Taliban are admitting to publicly. We are aware of constant killings and assassinations and terror.
"The media and the journalists have no access to this and so it is not being properly reported... As a Chief Judge I know I will be killed and my family too."
'Semantic hair-splitting'
The judge's solicitor told the OceanNewsUK his work had come at "immense personal risk" and he "was the subject of repeated threats, including a documented assassination attempt upon him in March 2020".
In his written judgement, Mr Justice Knowles said the grounds on which the panel had rejected the judge's application for relocation amounted to "semantic hair-splitting".
He said the MoD had failed to explain why working to uphold the rule of law in Afghanistan was "not sufficient to count as working 'alongside' and in 'support'" of the UK government.
He continued: "[The judge] performed significant activities which were closely aligned with the democracy-building and rule of law building activities of the UK government... He made significant contributions to the building of a properly functioning criminal justice system in the fields of terrorism, anti-narcotics, and anti-corruption, among others."
It is unclear how long it will take for the judge's application to be reassessed.
Responding to the ruling, a government spokesperson said: "We note the outcome of the court proceedings in relation to an ARAP-related case, which we are considering. It is inappropriate to comment further at this time.
"We continue to honour our commitment to those brave Afghans that supported the UK mission in Afghanistan.
"So far, we have brought around 27,900 people to safety from Afghanistan, including over 15,800 people from the ARAP scheme, including over 3,000 since October 2023."