NASHVILLE (AP) – A Tennessee judge who is being investigated after allegations that he helped a woman with her legal troubles in exchange for sex is facing federal charges of bribery, witness tampering and retaliating against a witness, prosecutors said Tuesday.

FBI agents arrested Davidson County General Sessions Judge Cason “Casey” Moreland on Tuesday at his sister’s home where he had been living, and he later appeared in court, shackled at the wrists and ankles. He was ordered to remain in custody, pending another hearing Friday, media outlets reported.

Moreland’s attorney, Peter Strianse, said his client is in a state of shock.

“He certainly didn’t expect to be welcomed by the Federal Bureau of Investigation at 6 o’clock this morning with a search warrant,” Strianse told reporters. “So I think he’s still reeling a bit from all of that.”

According to a criminal complaint, Moreland learned in February that the FBI was investigating him for possible corruption. That investigation is centered on allegations that Moreland extorted sexual favors as well as travel and lodging in return for official acts, such as having fines dismissed for defendants.

A female witness told the FBI she believed Moreland offered his help with her legal troubles with the expectation of receiving sex in return, and the two started their relationship in April 2016.

The woman told the FBI that Moreland helped her eliminate court costs and traffic ticket fines, got an interlock breathalyzer removed from her car, and aided her in avoiding a ticket for a suspended license during a traffic stop, the complaint states.

Moreland, 59, also tried to pay the female witness $6,100 through an intermediary in exchange for her signing an affidavit in which she would recant her statements about his improprieties, the complaint said.

At the FBI’s direction, the intermediary recorded the meeting, during which Moreland said, “this right here gets me out of trouble,” according to the complaint.

Moreland told an intermediary get the witness “liquored up real good” before mentioning the affidavit, which had been written as if she had authored it herself, and bought a temporary “burner” phone because he was worried about his phone calls being monitored, the complaint said.

In an attempt to further ruin the witness’s credibility, Moreland also schemed to plant drugs on the witness and have a police officer pull her over in a traffic stop, the complaint said.

“As the conduct outlined in the charging document makes clear, allowing Judge Moreland to continue to exercise the vast power over the lives of individuals as a sitting judge can severely jeopardize the constitutional protections afforded to our citizens,” Acting U.S. Attorney Jack Smith said at a news conference.

If convicted, Moreland faces up to 20 years in prison.

Nashville Mayor Megan Barry said Moreland’s immediate resignation “would seem to be in the best interest” of the city.