Scott Silverthorne built a reputation as a civic pillar of Fairfax City, Virginia, over three decades, helping bring a park to the affluent suburb’s downtown and championing other improvements during three terms as mayor.

But even as he was the public face of the city, police said the 50-year-old was privately leading another life online: using a website to swap methamphetamine for sex with other men.

Those seemingly incongruous sides of Silverthorne burst into public view Friday, as Fairfax County police announced the Democratic elected official had been charged following a sting in which they said he agreed to give an undercover officer the drug in exchange for an orgy at a Tysons hotel.

The arrest marked a stunning downfall for Silverthorne, who had followed his own father into the mayor’s office, recently beaten cancer and coped with the loss of his job and house. Through text messages, Silverthorne declined to discuss the charges.

The news shocked residents and city officials and clouded the future of projects Silverthorne was pushing. City Councilman Jeffrey Greenfield was appointed acting mayor of the city of 23,500 residents, which is 20 miles west of Washington.

“The city of Fairfax city council appreciates Mr. Silverthorne’s long-standing dedication to the community,” Greenfield said in a statement read to TV cameras outside City Hall. “The community has benefited from his dedication and his vision.”

One former political opponent showed up Friday at the city registrar’s office to figure out the process to run for mayor in a special election. Others simply expressed shock at seeing a man they watched rise through the ranks of local politics fall in such an unexpected way.

“The sad thing is you can spend 30 years building up your reputation and lose it in 30 minutes,” city councilman David Meyer said. “I think I can speak collectively that we’re concerned for the future of the city as well, but the city is greater than one person and we’re going to persevere.”

Fairfax County police said at a news conference that Silverthorne had admitted to distributing drugs. They said they began the investigation after receiving a tip in mid-July.

“We were provided with information from a citizen that the mayor was involved with a website,” Capt. Jack Hardin, commander of the Fairfax County police organized crime unit, said. “It was alleged he was exchanging meth for sex.”

Detectives created a fake profile on the site, which police declined to name, in an effort to lure Silverthorne, police said. Two days later, they said, Silverthorne messaged the account, saying he could provide drugs in exchange for group sex.

Two undercover officers arranged a meeting at the Crowne Plaza Hotel in Tysons around 7 p.m. Thursday, police said. The undercover officers met Silverthorne and two acquaintances in the parking lot.

The group waited about 20 minutes for Silverthorne’s methamphetamine supplier to arrive, police said. When he did, Silverthorne allegedly acquired about 2 grams of meth, then returned.

Silverthorne and an acquaintance, Caustin Lee McLaughlin, 21, of Maryland, were placed under arrest, police said. As police were trying to arrest McLaughlin, he resisted and was Tasered, police said. No one was injured during the encounter.

Afterward, detectives went into the hotel and arrested Juan Jose Fernandez, 34, of Maryland, who police said had supplied the drugs to Silverthorne and was at the bar. Silverthorne’s other acquaintance was released without being charged.

Silverthorne was charged with felony distribution of methamphetamine and misdemeanor possession of drug paraphernalia. McLaughlin and Fernandez also face drug charges, and McLaughlin was charged with obstruction of justice.

All three were transported to the Fairfax County jail, where McLaughlin and Fernandez remained Friday. The Fairfax County Public Defender’s Office, which represents Fernandez, did not return a call for comment, and court records did not list an attorney for McLaughlin.

Silverthorne was released on his own recognizance. He is set to be arraigned Wednesday.

On Friday, Silverthorne, in a text message, referred requests for comment to his attorney. “Wish I could speak to you but he’s asked to direct calls to him,” Silverthorne said.

Silverthorne’s attorney, Brian Drummond, said “given the fact that I haven’t had the opportunity to sit down and speak with my client, I’ll have no comment at this time.”

The arrest capped a period of tumult in Silverthorne’s personal life. In January, Silverthorne told The Washington Post, “It’s been a terrible year for me,” in reference to financial and medical problems.

“There’s no question about it,” he said at that time. “I can try to sugarcoat it as best I can, but the facts speak for themselves.”

In late June 2015, Silverthorne was laid off as a director of recruitment with the National Association of Manufacturers. He owed about $58,000 to various creditors and filed for federal bankruptcy protection.

A bank foreclosed on Silverthorne’s five-bedroom house, and he moved in with a friend. He was also battling neck cancer.

A Fairfax native, Silverthorne was elected in May to serve his third term in the nonpartisan office of mayor. He has previously served nine terms on the city council. And his father, the late Frederick Silverthorne, served as mayor of Fairfax City in the late 1970s and early 1980s.

Silverthorne worked briefly as a Fairfax County substitute teacher beginning in April, but he was terminated from the position on Friday, school district officials said.

With his cancer in remission, Silverthorne recently resumed the lead in efforts among local leaders to raise Fairfax City’s economic stature by redeveloping some old strip malls and other parcels in hopes of luring in developers.

As mayor, Silverthorne has been behind some key city improvements, most notably a green-space ordinance while he served on the city council about a decade ago that made it possible for the city to develop a downtown park.

Silverthorne also was key in easing tensions with a local center for the homeless after the city lost a Virginia Supreme Court battle four years ago that was part of an effort to push the organization out of Fairfax.

His arrest probably means Silverthorne will step down, some local officials said. With no vice mayor, the city council would have to schedule a special election for a new mayor, most probably in November. Silverthorne had not resigned as of Friday.

Still, John Norce, who ran for mayor against Silverthorne in 2012, wasted no time in trying to take advantage of the political disruption. “I’d be into again being involved if it helps the city,” he said after visiting the city registrar’s office to inquire about a special election.

Meanwhile, Silverthorne’s friends worried about his well-being.

“After such a rocky year financially and with his health, I had hoped that he turned a corner and was back on his feet, so this is awful,” said Fairfax County Board of Supervisors Chairman Sharon Bulova (D), who described Silverthorne as a champion for people in need of social services. “It’s just really very sad.”

Tom Ammazzalorso, Silverthorne’s challenger in the May election, said he felt sympathy for this one-time political opponent.

“My heart breaks for this man, because obviously he’s facing tremendous personal challenges,” Ammazzalorso said. “That’s not the way to conclude your political career. That’s absolutely terrible. It’s absolutely heartbreaking.”

The Washington Post’s Dana Hedgpeth, Tom Jackman and Fenit Nirappil contributed to this report.