A man convicted of murder in Oklahoma is being given a new trial after it was discovered that the judge who sentenced him had a sexual relationship with one of the prosecutors.

Robert Leon Hashagen III was convicted in February 2021 of murdering 94-year-old Evelyn Goodall in 2013.

Following revelations that Judge Timothy Henderson had an undisclosed sexual relationship with one of the prosecutors in the case, Hashagen's attorneys appealed his conviction. 

The Oklahoma Court of Criminal Appeals on Thursday ordered a new trial for Hashagen in a 3-2 decision that found "the undisclosed relationship violated Hashagen's due process rights."

LOVE TRIANGLE MURDER VICTIM IN HAWAII CHEATED WITH MULTIPLE WOMEN, DEFENSE ATTORNEY SAYS

Judge Timothy Henderson

Judge Timothy Henderson described the sexual involvement as consensual and said he maintained his role "as a neutral and detached judicial officer" at all times during the Hashagen case. (AP Photo/Sue Ogrocki)

"We find that the structural error cannot be found harmless as the sexual relationship between the trial judge and prosecutor 'affects the conduct of the entire trial and cannot be separated from it for the purpose of analysis,'" wrote Judge William Musseman, according to outlet The Oklahoman.

VIDEO SHOWS KEY WEST REAL ESTATE MOGUL FATALLY SHOOT FORMER HIGH SCHOOL STAR ATHLETE URINATING ON A WALL

The judge added, "The failure of the judge and prosecutor to scrupulously avoid the potential for an error of this kind is indeed a betrayal of the high ethical standards to which all legal professions should aspire."

Henderson, who is married, resigned in March 2021 after three female attorneys came forward with allegations of sexual misconduct against him.

Robert Hashagen III was convicted in February of murdering 94-year-old Evelyn Goodall in 2013.

Robert Hashagen III was convicted in February of murdering 94-year-old Evelyn Goodall in 2013. (Oklahoma County Jail)

CLICK HERE TO GET THE FOX NEWS APP

Henderson described the sexual involvement as consensual and said he maintained his role "as a neutral and detached judicial officer" at all times during the Hashagen case.

"My rulings were fair and supported by the evidence and facts presented by the attorneys," he said previously.

A special prosecutor's investigation into the claims against Henderson did not find evidence of nonconsensual sexual contact.

Fox News Digital's Stephen Sorace contributed to this report.