An anti-war activist today won "a partial victory" in her High Court challenge over Britain's policy of transferring captured Taliban suspects to the Afghan authorities.
Maya Evans said the policy had led to "horrible abuse" of detainees, violating international law and human rights.
Ms Evans, from St Leonards, East Sussex, accused members of the Afghan security service of "practising torture and ill-treatment with impunity".
Today, Lord Justice Richards and Mr Justice Cranston, sitting in London, said Ms Evans had won "a partial victory", but it was far from a complete victory as she had not succeeded in her attempt to stop all transfers being made.
Ms Evans is a prominent peace activist who was arrested for reading out the names of British soldiers killed in Iraq during a protest at the Cenotaph in London.
Her lawyers told the High Court that detainees handed over to the National Directorate of Security (NDS), a secret service organisation in Afghanistan, had suffered beatings, electrocution, sleep deprivation and being forced into stress positions, and undergone whipping with rubber cables.
Her solicitors, Public Interest Lawyers, documented several cases where prisoners had allegedly been abused.
Michael Fordham QC, appearing for Ms Evans, said in court the process of handing over suspect insurgents to the NDS was "emphatically not" compatible with Article 3 of the European Convention on Human Rights, which protects against inhuman and degrading treatment.
It also breached the UN convention against torture.
But the judges refused to rule the transfer policy unlawful.
Instead they considered the individual history of each NDS detention facility - NDS Kabul, NDS Kandahar and NDS Lashkar Gah, the last in Helmand province.
They ruled that a moratorium already in place on transfers to NDS Kabul should remain in place, without further exceptions.
They said: "There is a real risk that detainees transferred to NDS Kabul will be subjected to torture or serious mistreatment.
"Transfers would therefore be in breach of the Secretary of State's policy and unlawful."
But transfers could lawfully be made to NDS Kandahar and NDS Lashkar Gah, "provided that existing safeguards are strengthened by observance of specified conditions".
Isolated examples of abuse at those facilities "are possible, but the operation of the monitoring system - including observance of the specified conditions - will be sufficient to guard against abuse on such a scale as to give rise to a real risk of torture or serious mistreatment".
After the ruling, Ms Evans said outside court: "We are very pleased with the outcome.
"Transfers to Kabul have stopped as a result of this case and transfers to Kandahar and Lashkar Gah are now subject to conditions.
"The British must be able to access prisons and interview Afghan detainees privately and if any allegations of mistreatment or abuse are made by Afghan detainees, transfers must stop immediately."
She added: "We are really pleased that there has been change in policy as a result of this case and that the court has said that there is a serious risk of torture and mistreatment and that this policy must be in place to ensure that mistreatment doesn't occur."
Defence Secretary Liam Fox also welcomed the ruling.
He said: "I am pleased that today's High Court judgment rules that UK forces can lawfully continue to transfer UK captured insurgents to sovereign Afghan authorities.
"The claimant in this case sought to end the practice of transferring insurgents to Afghan custody. She failed to do so.
"Bringing to justice those who seek to kill and maim British troops, coalition forces and Afghan civilians, including through indiscriminate methods like the laying of roadside bombs, forms an essential part of our current operations.
"It makes Afghanistan a safer place for our service men and women, and it is our duty to do so.
"There is no place for the abuse of detainees. We have always recognised that this is a difficult and challenging area in which our people have to operate and that is why we have specific safeguards and monitoring arrangements in place. These will be reinforced in line with the court's recommendations.
"Working with international partners, under ISAF, the British Government will continue to support all efforts to further improve the Afghan judicial system."
Public Interest Lawyers (PIL), who acted for Ms Evans, said she had "won an important case" - but warned changes to the legal aid system meant "no case like this could be brought in the future".
Ms Evans is now considering a court challenge to the legality of those changes.
Phil Shiner of PIL said: "The Government's case has been exposed for what it is - an attempted cover-up of the truth that we were transferring Afghans knowing full well the NDS would likely torture them.
"The policy must now change in the light of this clear ruling.
"It is important to note that this case could not have shone a bright light on this disgraceful policy without our legal aid system.
"The Government have now changed the rules following political pressure from the MoD so that no case like this could be brought in the future.
"Maya Evans is about to start a fresh case to challenge those changes.
"The UK says it respects democratic principles and the rule of law, but this case shows that we don't always do so and it is vitally important that the Government can be held to account if it does not".
Evidence had been gathered for the court from many organisations - the Afghan Independent Human Rights Commission, Amnesty International, Human Rights Watch, and Human Rights First.
The UN itself had provided cogent evidence "to the effect that Afghans within Afghan facilities are regularly subjected to torture, and worse".
PIL said overall there were allegations of 66 cases of torture in Kabul, including the amputation of limbs, as well as electric shocks, deprivation of sleep, water and food.
There were also allegations "of beatings by rod and cable, scorching, abusive language, and the death of at least one detainee in NDS Department 17 in Kabul".
The High Court case had focused in particular on seven detainees, referred to as X, A, B, C, D, E and G.
PIL welcomed the court's ruling that it was not lawful for the Defence Secretary to transfer any Afghans to the NDS in Kabul, and that strict conditions must be observed before transfers can take place to the NDS at Kandahar and Lashkar Gar.
PIL said the conditions required UK monitoring teams to be given access to each transferee on a regular basis, with the opportunity on each occasion for a private interview - "individually, and in a room in which no guards are present".
Each transferee in practice had to be visited and interviewed in private on a regular basis.
The Defence Secretary "must consider the immediate suspension of further transfers if full access is denied at any point without an obviously good reason, or if a transferee makes allegations of torture or serious mistreatment by NDS staff which cannot reasonably and rapidly be dismissed as unfounded".