Read Pennsylvania Supreme Court's Full Ruling Releasing Bill Cosby From Prison

Bill Cosby is set to be released from prison after the Pennsylvania Supreme Court overturned his sexual assault conviction on Wednesday.

The state's highest court ruled that a "non-prosecution agreement" Cosby struck with a previous prosecutor should have prevented him from being charged in the case.

"When an unconditional charging decision is made publicly and with the intent to induce action and reliance by the defendant, and when the defendant does so to his detriment (and in some instances upon the advice of counsel), denying the defendant the benefit of that decision is an affront to fundamental fairness, particularly when it results in a criminal prosecution that was foregone for more than a decade," the high court wrote in their opinion.

"For these reasons, Cosby's convictions and judgment of sentence are vacated, and he is discharged," the judges wrote.

The state's highest court also barred any further prosecution in the case.

The former entertainer has been accused of sexual misconduct or rape by more than 60 women, but none of the other allegations have resulted in charges. Cosby has maintained he never engaged in non-consensual sex.

Cosby full ruling PA supreme court
Bill Cosby is set be released from prison after the Pennsylvania Supreme Court overturned his sexual assault conviction on Wednesday. In this photo, Cosby arrives for sentencing for his sexual assault trial at the Montgomery County Courthouse on September 24, 2018 in Norristown. Gilbert Carrasquillo/Getty Images

In 2018, he was convicted of drugging and sexually assaulting a woman named Andrea Constand in 2004. Constand, a former Temple University employee, said Cosby drugged and assaulted her at his Pennsylvania home after she came to him for career advice.

Constand first reported the alleged assault in 2005 to then-Montgomery County District Attorney Bruce Castor Jr. Castor ultimately decided not to file any charges, but Cosby gave testimony in the case that he gave quaaludes to women he was pursuing for sex.

Cosby was later charged by Castor's successors in 2015 for the alleged attack and arrested just before the 12-year statute of limitations expired. Cosby's lawyers have long argued that his decision to sit for a deposition in the 2005 suit hinged on a promise of immunity.

During his first trial, the judge only allowed one other accuser to testify against him. But after the jury deadlocked on their verdict, the judge allowed five other accusers to testify at the retrial.

Cosby has served more than two years of a three-to-10-year prison sentence. In May, he was denied parole, partly because of his refusal to admit guilt or acknowledge remorse. He's been serving his sentence in the State Correctional Institution at Phoenix, a suburb in Philadelphia.

Below is the full, 79-page ruling issued by the Pennsylvania Supreme Court on Wednesday.