Tosh Ackerman took part of what he thought was a Xanax pill to help him sleep one night three years ago. His girlfriend found the 29-year-old dead the next day.

The Xanax he obtained from an acquaintance was counterfeit, says his mother, Carrie Luther, who lives in Mount Hermon, Calif. Toxicology reports found it contained a fatal dose of fentanyl, a synthetic opioid often produced illicitly for the black market.

“It...