Nearly 200 prisoners and former inmates forced to stop taking drugs by going "cold turkey" are to receive payments.
The unspecified settlement followed claims the practice amounted to assault and a breach of human rights.
The claimants had been using heroin and other opiates and were understood to have been receiving alternative treatment before going to prison.
The Home Office said it "reluctantly" decided to settle out of court to "minimise costs to the taxpayer".
It said the cases dated back to the early 1990s.
The settlement originates from a test case earlier this year, when six claimants were given the green light to sue the Home Office.
They 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.
A Home Office spokesperson said the pay-outs would be awarded to 198 applicants, and not just the six involved in the test case.
Shadow home secretary David Davis said the Home Office could be setting a "disastrous" precedent by settling out-of-court.
The proceedings focused on six test cases chosen from a total pool of 198 claimants.
Many had been taking the heroin substitute methadone.
The claimants were bringing the action based on trespass, because they say they did not consent to the treatment, and for alleged clinical negligence.
Their barrister Richard Hermer told an earlier hearing in May: "Many of the prisoners were receiving methadone treatment before they entered prison and were upset at the short period of treatment using opiates they encountered in jail.
"Imposing the short, sharp detoxification is the issue."
Mr Davis suggested the government did not want to be "embarrassed by losing such a case under its own human rights legislation".
"Drugs are a scourge on society and completely undermine all our other efforts to fight crime. By doing this Mr Reid would be letting down the taxpayer, the victims of these offenders and the drug addicts themselves," he added.
Former Conservative prisons minister Ann Widdecombe said the settlement was "an insult to every victim and every law abiding person".
"As far as I'm concerned there is no human right to continue a drug habit when you go to prison.
"This Prison Service will be paying out money it should not be."
Prison Reform Trust director Juliet Lyon said the case could see courts "pause for thought" before using jail terms as a way of making sure an offender receives treatment.
"Our overcrowded jails are awash with petty, persistent offenders who commit crime to feed their drug habit," she said.
According to the editor of the Prisons Handbook, Mark Leech, two-thirds of crime is drug-related and Home Office research has shown that 643 drug addicts were responsible for well over 70,000 offences in one three-month period.
"Prisoners have the right to receive exactly the same type and standard of healthcare in prison as they would receive in the community," he said.
"Yet for the most part drug detoxification in prison is second-rate in standard and woefully short in its duration."
The National Drug Prevention Alliance said prisoners should not be able to get drugs in prison.
Peter Stoker of the group said: "Yes we want a health-orientated regime of treatment for prisoners, but we don't want something that bows down to their existing drug abuse and says we can't do anything about it."
The charity Drugscope said the government had pledged £28m funding for a treatment programme for inmates this financial year but the actual budget was set lower.
The Department of Health said it was spending £12m in the current financial year on the scheme and the level of funding would be maintained in 2007/08.
The programme, supplemented by the Home Office, aims to increase drug treatment for prisoners to allow them to fight their addiction before their release into the community, a spokeswoman said.