The number of Maryland deaths related to opioid overdoses surged to new highs in the first half of 2016, continuing a trend that has persisted despite state efforts to address the problem.

Maryland’s Department of Health and Mental Hygiene said Thursday that heroin-overdose fatalities jumped 68 percent, compared with the same six-month period last year, rising to 566 from January through June.

Deaths related to fentanyl, a powerful synthetic opioid, increased 268 percent, to 446, while prescription painkillers accounted for 210 deaths, an increase of more than 10 percent, compared with the same period last year.

“We want to make sure Marylanders know that — if they are grappling with substance use disorder and are taking illicit substances — they are on the path toward overdose, possibly death, and they need to seek treatment right away,” Health Secretary Van T. Mitchell said in a statement.

Fatalities in all three opioid categories have risen steadily in recent years. But deaths from fentanyl, which is often mixed with heroin, have spiked most dramatically.

The synthetic opioid, which killed rock legend Prince in April, accounted for 15 deaths during the first half of 2013, meaning that the number has increased nearly thirtyfold since then.

State health officials say fentanyl can be 50 to 100 times more potent than heroin and morphine. Many overdose deaths are caused by people unknowingly buying heroin or cocaine mixed with fentanyl to produce an especially strong high.

Heroin-related deaths have risen every year in Maryland since 2011, but the 68 percent increase during the first half of 2016 was the most drastic for any January-to-June period in the past six years. In the first half of 2012, the number of heroin-related fatalities jumped 53 percent.

Deaths from prescription pain medications have increased every year since 2012.

Gov. Larry Hogan (R), who lost a cousin to a heroin overdose, created a task force to study the rapid increase in opioid deaths and recommend plans for addressing it.

Based on the group’s input, he released more than $2 million last year to expand access to treatment in rural parts of the state, boost police efforts to disrupt drug trafficking, create a Baltimore-based outreach program for overdose survivors and launch a public-awareness campaign.

In 2016, the governor devoted $3 million in new spending to support addiction treatment in prisons and $2.3 million for a modest increase in the reimbursement rate for providers of drug-abuse treatment, in part to attract and retain more workers in the field.

Hogan and the legislature this year also approved legislation mandating that prescribers use a statewide database that tracks potential abuse of painkiller medications and notifies doctors, pharmacists, licensing boards and police of suspicious activity.

Additionally, the health department has authorized pharmacists to dispense an overdose-reversal drug without a prescription to more than 20,000 people who have been trained to use it since 2014.

Overdose deaths from opioids, including fentanyl, are on the rise in Virginia, as well. There were 859 such fatalities in a preliminary count of 2015 numbers from the Office of the Chief Medical Examiner. Of those deaths, 470 were related to heroin or fentanyl, the other 389 from prescription opioids. In a preliminary count from the first three months of 2016, there were 452 opioid deaths in Virginia.

“I’m very concerned that we haven’t seen the worst of this,” Dana J. Boente, the U.S. attorney for the Eastern District of Virginia, said at a forum in Loudoun County on Tuesday. “If you don’t know someone who’s had a problem with addiction, you will.”

His office has focused in recent years on prosecuting opiate dealers whose drugs have led to fatal overdoses.

Rachel Weiner contributed to this report.