TRENTON, N.J. — New data show that the number of prescriptions for opioid painkillers filled in the U.S. fell dramatically last year. They showed their biggest drop in 25 years.

The decline comes amid increasing legal restrictions and public awareness of the dangers of addiction.

A health data firm released a report Thursday showing a 9 percent average drop nationwide in the number of prescriptions for opioids filled by retail and mail-order pharmacies. All 50 states and the District of Columbia had declines of more than 5 percent.

Get Breaking News Delivered to Your Inbox

The U.S. is estimated to consume roughly 30 percent of all opioids used worldwide.

The number of prescriptions for opioid painkillers filled in the U.S. fell dramatically last year, showing their biggest drop in 25 years and continuing a decline amid increasing legal restrictions and public awareness of the dangers of addiction, new data show.

Health data firm IQVIA's Institute for Human Data Science released a report Thursday showing an 8.9 percent average drop nationwide in the number of prescriptions for opioids filled by retail and mail-order pharmacies. All 50 states and the District of Columbia had declines of more than 5 percent. Declines topped 10 percent in 18 states, including all of New England and other states hit hard by the opioid overdose epidemic, such as West Virginia and Pennsylvania.

"We're at a really critical moment in the country when everybody's paying attention to this issue," said Michael Kleinrock, the institute's research director. "People really don't want them if they can avoid them."

There was an even greater drop in total dosage of opioid prescriptions filled in 2017, down 12 percent from 2016. Reasons for that include more prescriptions being for a shorter duration, a 7.8 percent decline in new patients starting on opioid prescriptions and far fewer high-dose prescriptions.

Opioid doses are measured in "morphine milligram equivalents." (A standard Vicodin pill has the equivalent of 5 milligrams of morphine.) Prescriptions for dosages of 90 morphine milligram equivalents per day or more, which carry the highest addiction risk, declined by 16 percent last year, according to the report.

The U.S. is estimated to consume roughly 30 percent of all opioids used worldwide.

Opioid prescriptions and daily doses rose steadily starting in the 1990s, fueled by factors including marketing of new opioid pills such as Oxycontin. Use peaked in 2011 at levels far above those in other wealthy countries where national health systems control narcotics more aggressively.

The U.S. decline began after overdoses and deaths from prescription opioids and illicit narcotics soared, and multiple groups pushed back.

The federal government and about half the states have enacted restrictions, such as limiting the dose or duration of opioids that can be prescribed. Insurers and drug stores began imposing similar limits on opioid use for acute pain, as opposed to cancer and chronic pain patients. The Drug Enforcement Administration increased prosecution of heavy prescribers. And numerous medical groups have issued guidelines urging prescribers to offer other pain-management options when possible and to limit doses and duration of opioid prescriptions.

Despite those measures, deaths from drug overdoses have continued to increase in the U.S. and emergency rooms saw a big jump in overdoses from opioids last year, according to government data.

Doctors have been heeding the messages from medical groups, and some worry they'll be arrested or lose their license if they provide too many opioids, said Bob Twillman, executive director of the Academy of Integrative Pain Management, which represents doctors and others who treat pain patients.

"We get a lot of phone calls from patients whose primary care doctors have said they won't prescribe opioids at all," and want referrals to other doctors, Twillman said.

The opioid data are part of IQVIA's annual report on U.S. drug-spending trends. It noted that last year the total spent on prescription drugs, after multiple discounts and rebates drugmakers give to middlemen, was $324 billion, up 0.6 percent. The report forecasts that after such discounts, drug spending will rise by 2 percent to 5 percent annually for the next five years.