RIVERHEAD, N.Y. (CBSNewYork) — A highly regarded medical doctor who also served as a distinguished county legislator was arrested last year on drug- and prostitution-related charges.

On Monday, the shocking indictment was unsealed in a Riverhead courtroom, CBS2’s Jennifer McLogan reported.

READ MORE: Gov. Hochul Signs Bills Aimed At Combating Opioid Crisis

“Just imagine you are a medical doctor and a legislator and all that has come to a crashing end, for now. For now,” defense attorney Anthony Lapinta said.

Dr. William Spencer, a Suffolk County legislator, appeared shattered and emotional as he left Criminal Court, after an unsealed indictment accused him of trying to swap oxycodone pills for sex.

“We entered a plea of not guilty. We have demanded a trial,” Lapinta said.

The doctor faces up to nine years. Seven of the nine counts against him are felonies and include possessing and selling a controlled substance, patronizing a person for prostitution, and perjury.

In a written statement, he told police, “I have not sought the services of prostitutes or call girls.”

Prosecutors claim to have proof he texted with a sex worker to meet him behind an East Northport strip mall to exchange drugs for sexual favors. The phone was in the hands of the Drug Enforcement Agency.

Prosecutors say Spencer, dressed in medical scrubs, drove his county car there, and was arrested in possession of oxycodone, condoms, and a loaded handgun for which he had a permit, McLogan reported.

READ MORE: Judge Conditionally Approves Purdue Pharma Opioid Settlement

“He should definitely be held to a higher standard considering he is a lawmaker,” one person said.

“I am a sober person. I was an addict at one point, and I got my meds from my doctors,” another person said.

“He was elected to keep community safe. He is a doctor there to help people. It’s exploiting someone based on one of their biggest vulnerabilities, which is addiction. He’s offering them drugs for sex. That is clear exploitation. That is coercion. This is a huge problem,” said Keith Scott of Safe Center LI.

“Doc Spencer,” as he is affectionately called by his Huntington constituents, is a married father of three. He led the crusade against opioid addiction as a respected legislator and physician.

“Despite this indictment, there is an incredible number of people that support William Spencer,” Lapinta said.

Spencer claims he was the victim of a pimp’s extortion and was lured and targeted.

He did not run for re-election. His legislative term ends Jan. 1.

MORE NEWS: Westchester Police Departments Partner With Nonprofit Hope Not Handcuffs To Offer Substance Abuse Treatment

Editor’s note: This story first appeared on Nov. 8.

Jennifer McLogan