An end to the prohibition of medical marijuana in the US might prevent tens of thousands of deaths every year from prescription drug overdoses, new research suggests.

In states that have decriminalized medical weed, an average of 25 percent fewer people are dying from overdoses of opioid analgesics each year compared to the nation as a whole, according to a scientific paper published in JAMA Internal Medicine. That is 1,729 less deaths than expected for every state that had legalized medical marijuana in 2010, the study’s final year.