(CNN) The Massachusetts Supreme Judicial Court ruled Monday that it was not cruel and unusual punishment to put a person who is on probation in jail after one positive test for drugs.

Experts have been watching the case closely, as thousands of people who struggle with substance use disorder find themselves caught up in the nation's judicial system amid the country's opioid epidemic.

"The decision is a massive blow, and I believe, on the wrong side of history," Lisa Newman-Polk, the attorney who represented the defendant in the case, said on Monday.

As a lawyer and a certified social worker with clinical experience treating addiction and other mental health disorders, Newman-Polk said before the decision she was "so frustrated, in effect, by what I saw was a misunderstanding by the judges that I was going before, who have this mistaken idea about the nature of substance use disorder and what actually helped someone get into recovery.

"This whole concept of threatening people to stop using is totally ineffective."

The court did not agree and concluded that "in appropriate circumstances, a judge may order a defendant who is addicted to drugs to remain drug free as a condition of probation, and that a defendant may be found to be in violation of his or her probation by subsequently testing positive for an illegal drug."

The conditions set out by the judge "furthered the rehabilitative goal of probation by facilitating treatment for the defendant's drug addiction" and protected the public because the "defendant's drug use motivated her to commit the crime."

The Commonwealth v. Julie Eldred

The crime at the heart of the case was committed by 30-year-old Julie Eldred, one of an estimated 2.1 million Americans with an opioid use disorder.

Although she is doing better now, according to Newman-Polk, Eldred struggled with drugs for nearly half her life. As a 14-year-old in high school, she used alcohol, tobacco and marijuana to self-medicate and manage anxiety, depression and attention deficit hyperactivity disorder. By August 2016, she was had been diagnosed with a severe substance use disorder and wound up in front of a judge, charged with stealing jewelry from a client for whom she provided dog-walking services. She sold it to pay for more drugs.

She'd never been in legal trouble before, and the judge gave her probation and told her she could stay out of jail if she went to rehab, remained drug free and submitted to random testing.

but she relapsed. An outpatient program seemed to help, but Eldred still craved fentanyl, an highly addictive narcotic painkiller that's 100 times more potent than morphine. To suppress her cravings and withdrawal symptoms, a doctor gave her a prescription for Suboxone , a drug used to treat opioid addiction,but she relapsed. About 88% of people do , even after treatment and complete opioid detoxification, one study found.

Trying again to stay clean, she got a stronger dose of Suboxone from her doctor. But 12 days after she got probation, a court-ordered drug test detected fentanyl.

She hadn't stolen again or broken any other laws, but the judge sent her to jail until her lawyer could get her back into rehab. Newman-Polk argued in court that the requirement that Eldred remain drug-free to avoid jail was unconstitutional because, in part, her relapse was a symptom of her substance use disorder.

Eldred said in court that she had "every sincere intention of being drug free" but couldn't "control the compulsion to use."

Rehab spaces are hard to find, Newman-Polk said, and Eldred sat behind bars for 10 days without treatment and without Suboxone until a spot became available at a rehab facility. That is cruel and unusual punishment, Newman-Polk argued before the court in 2017.

"Jail is not what helped her," she told CNN. "Jail was an interference with her treatment."

The commonwealth , on the other hand, argued in court that the detention was not only permissible, it "may have helped to save her life, given the dangerous nature of fentanyl."

The Massachusetts Supreme Judicial Court concluded Monday that "judges should act with flexibility, sensitivity, and compassion when dealing with people who suffer from drug addiction." A judge should have the "flexibility at each stage of the process" because of the "rehabilitative goals of probation."

"This individualized approach to probation fosters an environment that enables and encourages recovery, while recognizing that relapse is part of recovery," the court decision said. The punishment was not for drug use but for "the underlying crime."

Margaret Quackenbush, a spokeswoman for the Attorney General's Office, said in a statement Monday that "Our office is committed to improving access to substance-use treatment in all its forms. We are pleased the Supreme Judicial Court today affirmed a court's ability to take an individualized approach to probation that encourages recovery and rehabilitation to help probationers avoid further incarceration."

Newman-Polk said the case was to test the court's current practice. Her client, she said, suffers from substance use disorder in which her "continued use of substances despite negative consequences is a symptom of that disorder."

"The (Massachusetts Supreme Judicial Court) had the opportunity to do something groundbreaking in view of the science in the Surgeon General's report on substance use disorder and instead rubber-stamped the status quo, dysfunctional way in which our criminal justice system treats people suffering from addiction," Newman-Polk said after the decision was announced on Monday.

The case has pitted drug experts against each other and challenges the very notion of what addiction is and what role the courts should play in it.

The question has become even more relevant as the opioid epidemic grows. Opioid overdoses in the United States increased 30% from July 2016 to September 2017 alone, according to government statistics.

Changing thinking on drugs

Some legal experts say that much of our current drug law was created in the time of Prohibition.

In the 1920s, prominent doctors believed that the "addiction evil" -- as Dr. Alfred C. Prentice, a member of the American Medical Association's Committee on Narcotic Drugs, called it -- was an affliction of the "weak-minded." Treating substance use disorder as a disease was a "shallow pretense" by "incompetent" doctors, he wrote in the Journal of the American Medical Association , that was meant to help doctors whose patients had a "complete perversion of the moral nature" and were "a source of danger to every one, both physical and moral."

Dozens more medical scholars went on to perpetuate what the US government's National Institute on Drug Abuse now calls "myths," and with respect to these sentiments, laws were created to punish rather than to prevent or treat the "moral failing" of drug use.

In court arguments on Eldred's case, the Massachusetts Attorney General's Office argued that there is now "wide consensus" that the "old-fashioned moralistic approach has been discredited and is no longer prevalent." It says many on Eldred's case, the Massachusetts Attorney General's Office argued that there is now "wide consensus" that the "old-fashioned moralistic approach has been discredited and is no longer prevalent." It says many in the courts agree that an "exclusively punitive response to addiction in the criminal justice system" was not effective.

Yet the threat of jail can help someone get clean, the commonwealth argued. The National Association of Drug Court Professionals wrote in an amicus brief in support of neither party that "graduated sanctions are an evidence-based and effective intervention in substance use disorder."

Eldred's condition is different from something like asthma. "Rewards and sanctions" used in current court treatment can influence the behavior that is a consequence of this condition, and people with this disease "retain at least some capacity to exercise control over their drug use," the commonwealth argued. Drug testing is necessary to monitor a person's progress. It is "indispensable for promoting public safety and helping defendants with (substance use disorder) to achieve recovery."

A brain disease

Newman-Polk took a different approach and was joined by several health professional and legal scholars who wrote briefs in support of her argument. Since the 1920s, the science has evolved, and these experts argued that the courts haven't kept up.

"This case is emblematic of what role the system plays, and there are a lot of things the system does that is counterproductive from a public health standpoint," said Leo Beletsky , an associate professor of law and health sciences at Northeastern University who contributed to an amicus brief in the Eldred case.

Beletsky thinks jail or prison provides only limited assistance for some people with drug problems. "It's important to keep in mind that recovery is an ongoing process rather than a discrete terminal event," he said.

Beletsky called Monday's court decision "very disappointing" and added in an email that it "underscores just how deeply the stigma of addiction runs in our laws and jurisprudence. There is much work yet to be done to bring scientific evidence on addiction to bear on the criminal justice system."

Many experts agree that addiction is a "disease that affects both the brain and behavior," according to the National Institutes of Health.

Brain images show that substance use disorder physically changes in areas that are essential for behavior control and decision making, making it difficult to fight the impulse to take drugs, even if a court threatens punishment. That means periodic relapse, like Eldred's, is probably going to be a part of recovery, and punishing these people for their illness is "morally indefensible," Newman-Polk argued in court.

Despite the science, Doug Berman sees the debate play out in his own law classes.

Students don't typically blame a sleepwalker or hypnotized person who is unable to stop their behavior, even if it is dangerous, but when it comes to drugs or mental illness, it's hard for many to "discard blameworthiness," said Berman, the Robert J. Watkins/Procter & Gamble Professor of Law at the Ohio State University's Moritz College of Law and an expert in sentencing and drug law.

Berman is not affiliated with the case but watched it closely. "I think there is a degree of righteous concern about drug use being criminalized this way," he said.

y. Treatment doesn't have to be voluntary to be effective, and monitoring can be a powerful incentive, The commonwealth argued that the "brain disease" science is still "controversial" and "not sufficiently developed" enough for the courts to rely on it in this constitutional question. The court agreed on MondaTreatment doesn't have to be voluntary to be effective, and monitoring can be a powerful incentive, studies show.

The court disagreed with the characterization that the probation condition was based "on an outdated moral judgment about an individual's addiction." Rather, the lower-court judge based her decision on the consideration of the circumstances, and "judges cannot ignore the fact that relapse is dangerous for the person who may be in the throes of addiction and, often times, for the community in which that person lives," according to Monday's decision.

Judges who are on the "front lines of the opioid epidemic," the decision said, often are "faced with difficult decisions that are especially unpalatable."

Of the science, Berman said, more research is needed. "I think we don't fully understand what drives human behavior as a general matter and what is at the fundamental core of substance abuse disorder, but two things we do know is everyone is different, and what will deter some may not deter others," Berman said.

Throw fentanyl into the mix, and the case becomes even more complicated.

"Where we are in the opioid epidemic with fentanyl, a drug we've concluded is addictive at a level that may be more compelling than any other, we remain in part sympathetic to uncontrollable addiction, and we are also in tune with the idea that if (Eldred) can escape responsibility for her actions, what about the next case?" Berman asked.

As a matter of case law, he said, "It would be terrible to say 'we can't punish her generally,' " but it is also a "particularly bad idea to send people on parole or supervision immediately back to prison simply for one dirty urine (test). That's the worst way to respond. It increases incarceration rates. It's really bad policy." That's why many states are moving away from this punitive model, he said: It doesn't totally work for everyone, studies show.

What will work to help people with substance use disorder is still up for debate.

The impact of the case

Beletsky thinks this won't be the last time the case comes up.

"This case itself won't change things, but it's the first of many that starts to chip away at the idea that criminalization is the way to address problematic substance abuse," he said. "The courts haven't kept up with the science itself. It's time."

Follow CNN Health on Facebook and Twitter See the latest news and share your comments with CNN Health on Facebook and Twitter.

As for Eldred, Newman-Polk said, she is off probation and is in "a good spot, and I always say that with cautious optimism."

Since last year when she argued the case, Newman-Polk's gotten calls and letters from lawyers and judges who are encouraged by her fight. Even without the win, "the idea to get the public to think about this is a win, and at least we've moved the needle a little."