Patrick J. Thomas was a longtime heroin user who helped pay for his habit by buying extra bags and then selling them to various pals around Ocean City. One night in June 2015, Thomas sold four bags of “Banshee”-brand heroin to a young acquaintance named Colton Matrey, himself no stranger to the drug.

Matrey, 23, shot all four bags and died, court records show. Thomas was surprised, since four bags was his own usual dosage, and mortified, the police reported. Prosecutors in Worcester County charged him with manslaughter and Thomas, then 58, was convicted. And last month, Maryland’s highest court affirmed the conviction, the first time an appeals court in the state approved using homicide laws to prosecute drug dealers after an overdose.

As the opioid crisis surges on, 20 states and the federal government have enacted laws specifically to prosecute drug dealers after fatal overdoses, and an additional 16 states are using existing manslaughter laws to do the same, according to the Drug Policy Alliance. Some civil libertarians say that prosecuting dealers has no impact on opioid abuse, citing a recent report from the Pew Charitable Trusts that found “no statistically significant relationship” between state drug imprisonment rates and drug use, overdose deaths and drug arrests.

But prosecutors say they are not seeking to prosecute every overdose, regardless of any political clamor for victories in the “drug war.”

“It’s about each case,” said J. Charles Smith III, the Frederick County, Md., state’s attorney and a National District Attorneys Association board member. “It’s one of many ways we can combat a national crisis, like closing down a ‘pill mill.’ But we don’t have a blanket policy that addresses cases across the board. We are sincerely looking at the facts of each and every case.”

Maryland’s legislature has considered and rejected laws that would target drug dealers in fatal overdose cases. Virginia’s General Assembly passed such a law this year, but Gov. Ralph Northam (D) vetoed it, saying, “This bill goes beyond drug dealers and would punish individuals who are themselves struggling with addiction.”

After the cocaine-overdose death of Maryland basketball star Len Bias in 1986, Congress passed a federal law imposing a 20-year minimum sentence for anyone distributing drugs that result in death. Bias had apparently taken a highly potent form of cocaine.

“There’s not a shred of evidence that these laws work. It certainly doesn’t deter drug selling,” Lindsay LaSalle, a senior s taff attorney with the Drug Policy Alliance, told The Washington Post last year. In her 2017 report “An Overdose Death Is Not Murder: Why Drug-Inducted Homicide Laws Are Counterproductive and Inhumane,” LaSalle noted that “death tolls continue to climb across the country, even in the states and counties most aggressively prosecuting drug-induced homicide cases.”

Prosecutors have recently targeted dealers of fentanyl, a particularly deadly drug responsible for soaring numbers of overdoses in recent years. In York County, Pa., the district attorney’s office charged 45 people with drug delivery resulting in death over a three-year period.

Paul DeWolfe, the chief public defender in Maryland, said, “We’ve tried a lot of these [fatal overdose] cases across the state, and jurors have rejected the homicide piece of it” while convicting on the drug counts, which can carry 20-year terms. He said that “most of the drug dealers that are caught up in these cases are users themselves” and that prosecuting them for a death that occurred elsewhere, without any specific intent from the dealer, “turns generations of homicide law on its head.”

But the Maryland Court of Appeals, the state’s supreme court, focused on the recklessness of the drug deal between Thomas and Matrey to set a new precedent in Maryland. In an opinion written by Judge Sally D. Adkins, the court acknowledged that not all heroin distribution resulting in death constitutes manslaughter.

But, Adkins noted, “involuntary manslaughter does not involve an intent to kill, but only a reckless disregard of another person’s life.” She found that Thomas knew heroin could kill, that Matrey was desperate to use some — he had called Thomas 27 times in a 22-minute period — and that Thomas was unaware of the potency of his product.

Thomas “either willfully failed to obtain the necessary information to help reduce the risks of his behavior,” Adkins wrote, “or he was indifferent to mitigating these risks.” That amounted to a “wanton and reckless disregard for human life,” Adkins concluded, and so Thomas was guilty of gross negligence involuntary manslaughter.

The court split 4 to 3, and in a dissenting opinion by Judge Michele D. Hotten, the minority said that Thomas’s sale of heroin “was not ‘reasonably related’ to the fatal use of the substance by Mr. Matrey where the consumption occurred outside of Mr. Thomas’s presence, at a different time, in a different place from the completed sale, and with no other involvement from Mr. Thomas.”

DeWolfe, whose office represented Thomas, said the decision “will certainly encourage prosecutors to file more manslaughter cases. But jurors get it. A person selling a batch of drugs is not intending to kill anyone.”

Maryland Attorney General Brian E. Frosh (D), whose office successfully argued the Thomas case, said that prosecutors will not presume homicidal intent with every overdose but that “the prosecutor ought to have the ability to charge somebody with involuntary manslaughter when the circumstances justify it.”

Frosh said prosecutors “shouldn’t be out there prosecuting addicts for their addiction. But when we’re talking about drug dealers, they are selling stuff that is inherently dangerous and has the potential for lethality. They should not escape liability, even for crimes as high as involuntary manslaughter, just because they didn’t know the victim was going to overdose.”