PROVIDENCE, R.I. — A state judge accused of sexual harassment and judicial misconduct has announced that he will retire rather than continue to fight a recommendation that he be fired.

Judge Rafael Ovalles, in a letter dated Thursday, told Democratic Gov. Gina Raimondo that he will resign effective Oct. 31.

The state Commission on Judicial Tenure and Discipline launched an investigation into Ovalles in 2014. He was suspended with pay in December 2015.

A commission report found that Ovalles had degraded women, mistreated court staff, lawyers and the public and napped on the job. It recommended he be removed from the bench.

He denied the allegations but said in his resignation letter that his “ability to serve effectively has been compromised as a result of the disciplinary complaints filed against me.”

The Providence Journal reported Friday that the Administrative Office of the State Courts ruled Ovalles isn’t entitled to a pension.

A lawyer for Ovalles, former Providence Mayor Angel Taveras, said that state law allows for the revocation of a pension only when a public employee has been convicted of a crime related to employment.

“Judge Ovalles was an active and contributing member of the state retirement system for over 12 years and will continue to defend his rights to retirement benefits, which he is entitled to upon reaching the age of 65,” Taveras said.

Ovalles continues to receive an annual $160,018 salary.