Payments totalling £750,000 will go to 197 prisoners and former inmates forced to stop taking drugs by going "cold turkey" in jail.
The damages, approved by a High Court judge, follow their claims that the practice amounted to an assault and breach of human rights.
The Home Office "reluctantly" opted on Monday to settle a test case involving six men out of court to minimise costs.
It said the cases dated back to the early 1990s.
The six men said once in jail, and under the responsibility of the Prison Service in England and Wales, they were made to go "cold turkey" - where drugs are withdrawn or cut short.
They had used heroin and other opiates and were understood to have received alternative treatment before prison.
The claimants brought the action based on trespass, because they say they did not consent to the treatment, and for alleged clinical negligence.
Lawyers said all 197 can now expect to receive over £3,750 each.
They said all inmates had agreed to the deal, except for two who have yet to make their decision.
In court, Richard Hermer, who appeared for the six test case inmates, said the Home Office had admitted its policy on drug-dependent prisoners was unlawful and "inevitably means that such a policy must be changed with immediate effect".
He said the case was essentially "a medical negligence claim - not a human rights claim" which identified "the minimum standard of treatment deemed reasonable to treat individuals with drug dependency problems".
He said that the the Prison Service had "accepted that they failed to provide this minimum standard".
Mr Hermer added that had the matter gone to full trial inmates' evidence would have shown the "inadequacies" of treatment, which he said caused short-term suffering and was also counter-productive to rehabilitation.