The mayor of the City of Fairfax, Virginia, has announced his resignation after he was arrested for allegedly giving methamphetamine to an undercover detective in exchange for a sexual encounter.

According to a press release from the City of Fairfax City Council, R. Scott Silverthorne will resign from his position, effective Thursday, Aug. 11 at noon. Silverthorne appointed Councilman Jeff Greenfield acting mayor, but city council has scheduled a special meeting Tuesday night.

"It has been an honor and priviledge to serve our community, which has been my lifelong home," wrote Silverthorne in his letter to city residents and the member of the City Council.

Silverthorne waived his formal arraignment, which was scheduled for Wednesday.

Silverthorne was arrested Aug. 4 at a Tysons Corner hotel after police received a tip that he may have been trading meth for sex on a website used to arrange casual sexual encounters between men.

An undercover detective created a profile on the website, and Silverthorne contacted him within a few days, according to police.

Silverthorne allegedly told the detective he could provide meth "in exchange for sexual encounters," police said. The detective agreed to meet with Silverthorne, who agreed to bring other men to the engagement, according to police.

Police said Silverthorne brought the meth to the Chain Bridge Road hotel on Thursday. He was arrested and charged with felony distribution of methamphetamine and misdemeanor possession of drug paraphernalia.

Authorities said they don't know how long Silverthorne was on the website, which police did not identify.

"I know he had one other relationship on the website besides us," Capt. Jack Harden with Fairfax County police said during a news conference Friday.

Police said Silverthorne also served as a substitute teacher for Fairfax County Public Schools. A spokesman for the school district told NBC News that Silverthorne worked "briefly" as a FCPS substitute teacher starting in April 2016 and that he has been let go.

Silverthorne's arrest comes amid a trying year for him. He lost his full-time civilian job, lost his home and was diagnosed with cancer.

In May, he was re-elected to a third term as mayor after being elected to the position in 2012.

Investigators also arrested Silverthorne's alleged suppliers, Juan Jose Fernandez, 34, and Caustin Lee McLaughlin, 21.

Fernandez was charged with felony distribution of methamphetamine, felony possession with the intent to distribute methamphetamine and misdemeanor possession of drug paraphernalia.

McLaughlin was charged with felony distribution of methamphetamine, felony obstruction of justice, and misdemeanor possession of drug paraphernalia.