A Virginia doctor was sentenced to 40 years in prison on Wednesday for prescribing a half-million doses of opioids to patients over two years, prosecutors said.

Dr. Joel Smithers, 36, was sentenced in U.S. District Court in Abingdon. He was found guilty in May of more than 800 counts of illegally prescribing opioids, including oxycodone and oxymorphone that killed a West Virginia woman.

Smithers prescribed more than 500,000 doses of opioids to patients from Virginia, Kentucky, West Virginia, Ohio and Tennessee while based in Martinsville, Va., from 2015 to 2017, authorities said.

This physician perpetuated, on a massive scale, the vicious cycle of addiction and despair. — U.S. Attorney Thomas Cullen

U.S. Attorney Thomas Cullen said Smithers’ sentence, while severe, “serves as just punishment” for his actions. “This physician perpetuated, on a massive scale, the vicious cycle of addiction and despair,” Cullen said in a statement.

10 OVERDOSE DEATHS IN OHIO COUNTRY IN 26-HOUR PERIOD, CORONER SAYS

Smithers, a married father of five from Greensboro, N.C., testified that he was a caring doctor who was deceived by some of his patients.

Some patients remained fiercely loyal to him, testifying that they needed the powerful opioids he prescribed to cope with chronic pain.

Judge James Jones recommended that Smithers serve his sentence in a prison close to his family, and that he receive mental health treatment, WSET-TV reported.

Smithers was also ordered to pay an $86,000 fine and serve three years of supervised release after his prison term, according to court documents.

CLICK HERE TO GET THE FOX NEWS APP

Smithers wrote in a court filing that he plans an appeal. His attorney did not immediately respond to an email seeking comment on the sentence.

Fox News' Brie Stimson and The Associated Press contributed to this report.