UK troops can continue to transfer Taliban suspects to Afghan detention but not to a Kabul site subject to an existing ban, the High Court has ruled.
The legal challenge by anti-war activist Maya Evans, from East Sussex, claimed the policy led to "horrible abuse" and violated international law.
Judges said the practise could continue with other detention facilities if existing safeguards were strengthened.
The government welcomed the decision and said monitoring was in place.
The High Court judges said Ms Evans had won "a partial victory" but had not succeeded in her attempt to stop all transfers.
Ms Evans's lawyers told the High Court that detainees handed over to the National Directorate of Security (NDS), a secret service organisation in Afghanistan, had been tortured.
They said detainees had suffered beatings, electrocution, sleep deprivation, been forced into stress positions, and undergone whipping with rubber cables.
They also said the process of handing over suspect insurgents to the NDS was "emphatically not" compatible with Article 3 of the European Convention on Human Rights.
But the judges refused to rule the transfer policy unlawful, considering instead the individual history of each NDS detention facility - NDS Kabul, NDS Kandahar and NDS Lashkar Gah.
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."
Transfers could lawfully be made to NDS Kandahar and NDS Lashkar Gah, "provided that existing safeguards are strengthened by observance of specified conditions".
The judges also ruled that 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".
Ms Evans, from St Leonards, is a peace activist who was arrested for reading out the names of British soldiers killed in Iraq during a protest at the Cenotaph in London.
Speaking outside court, she said: "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."
Defence Secretary Liam Fox said he also welcomed the ruling.
He said: "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.
"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."