Deaths from opioid-related overdoses declined in 2018 for the second consecutive year, according to state figures released Wednesday that officials said showed signs of progress in the fight against an epidemic that took nearly 2,000 lives last year.

Total confirmed and estimated opioid-related deaths dropped from 2,056 in 2017 to 1,974 in 2018, or about 4 percent. From 2016 to 2017, the figure decreased 2 percent.

The death rate is still significantly higher than it was before it began climbing rapidly at the start of the decade, but state officials said two straight years of decreases should be seen as evidence that efforts to support treatment programs, to improve access to the overdose-reversing drug naloxone and to raise awareness about the risks of addiction are working.

"When you look from 2016 to now, we are making progress," Department of Public Health Commissioner Monica Bharel said Wednesday after a meeting of the Public Health Council. "We are making progress and fighting this devastating opioid epidemic. We've seen a 6 percent decrease, we know the efforts we have in place are beginning to work, and importantly, to me, from a public health point of view, we have to continue our sustained work to bring those deaths down further."

A key area of improvement in recent years has been a reduction in Schedule II opioids prescribed by doctors to treat pain, such as oxycodone and methadone. Experts warn that those medications can trigger addiction and create pathways to use of illegal heroin or other drugs.

In 2015, in an attempt to curb overprescribing, the state revamped its Prescription Monitoring Program and began requiring doctors to use it to track what was being given to patients and in what quantity. Between the first quarter of 2015 and the fourth quarter of 2018, Schedule II prescriptions written decreased about 35 percent.

Despite the optimism about making a dent in the crisis, several critical concerns remain.

Opioid-related overdoses still account for almost 40 percent of all deaths for adults between 25 and 34 years old. Recovery has been uneven across demographic groups, with deaths in recent years increasing among black males and decreasing among all other groups. And fentanyl, a synthetic opioid up to 50 times more potent than heroin, is becoming more prevalent.

"While we are encouraged to see fewer opioid-related overdose deaths for a second consecutive year and a 35 percent decrease in reported opioid prescriptions since 2015, the opioid epidemic continues to present a very serious challenge that is made more difficult due to the presence of fentanyl," said Gov. Charlie Baker said in a statement.

The state has tracked toxicology reports on overdose deaths, which involve many but not all cases, each quarter since 2014. When that effort first started, substances likely to be heroin were present in almost 70 percent of cases and fentanyl was present in less than 30 percent. But in the third quarter of 2018, the most recent for which data is available, fentanyl was detected in 89 percent of of post-overdose death toxicology reports, far more than any other substance.

Most of the deaths related to fentanyl come from illegally produced batches of the substance that are then mixed into heroin or cocaine, making what would be a typical dose dozens of times more powerful. Drug users often do not know that fentanyl is present.

Baker's fiscal year 2020 budget filed last month includes $266 million to fund treatment and opioid-related services, and the governor has also proposed spending $5 million on a Regional Fentanyl Interdiction Task Force to limit the spread of the substance.

"One of the most important public health interventions is awareness and education," Bharel said. "When people are using illicit drugs, they have to be aware of fentanyl, that fentanyl is deadly, that fentanyl is present in almost all of the opioid deaths right now."

Bharel also pointed out a key trend in the state's data: not all people are experiencing the opioid epidemic in the same way. While overall opioid deaths are down slightly, confirmed overdose-related deaths among those aged 25 to 34 have increased three years in a row. In 2018, 40 percent of all deaths for that group were related to opioid overdoses.

The death rate from opioid overdoses decreased for most demographic groups from 2014 to 2017, but increased for black males in that same timespan. Bharel said state experts do not yet know what is driving that disparity, but that public-awareness campaigns in communities of color have been running in recent months.

"For us at the state level and also at the community level, that gives us the opportunity to say, 'Let's make sure we're engaging and investing in every community,'" Bharel said. "There are some of us who are at highest risk. We want to make sure our work focuses on them."