The city started, in 2003, with North America’s first legal injection facility, InSite, which currently serves around 800 people each day. The addicts bring their own drugs, and InSite provides clean needles and medical supervision. The organization has recorded no fatal overdoses on its premises, and said overdoses near the facility have decreased by 35 percent since 2003, compared with a 9 percent decrease throughout Vancouver.

More broadly, a study by the British Columbia Center for Excellence in HIV/AIDS found that people who use safe injection sites are 30 percent more likely to enter detox programs and 70 percent less likely to share needles.

Legal injection sites do not, however, address the thefts, prostitution and other criminal behavior that participants often rely on to finance their addiction. And heroin sold on the street is often combined with — or surreptitiously replaced by — fentanyl, an opioid up to 50 times as potent that was a cause or contributing factor in 655 deaths across Canada from 2009 to 2014, according to the Canadian Center on Substance Abuse.

Participants in the Crosstown prescription program do not have to worry about the purity of their drugs.

To get a diacetylmorphine prescription from the clinic, patients must have participated in two earlier clinical trials on heroin maintenance, whose eligibility requirements included more than five years of injecting opioids and at least two failed attempts at replacement therapy, one of which with a treatment such as methadone.

The first trial, known as the North American Opiate Medication Initiative, followed users from 2005 to 2008, and found that prescribing diacetylmorphine could save an average of $40,000 in lifetime societal costs per person compared with methadone treatment. The second trial, whose results were published this month in The Journal of the American Medical Association Psychiatry, found that injectable hydromorphone, a licensed pain medication, can be as successful as diacetylmorphine in treating a chronic opioid addiction.