(287788)

Pennsylvania’s highest court on Wednesday overturned Bill Cosby’s sex assault conviction after finding an agreement with a previous prosecutor prevented him from being charged in the case. The actor/comedian was released from prison Wednesday.

Cosby served more than two years of a three- to 10-year sentence at a state prison near Philadelphia. He had vowed to serve all 10 years rather than acknowledge any wrong doing over the 2004 encounter with accuser Andrea Constand.

The 83-year-old Cosby, who was once beloved as “America’s Dad,” was convicted of drugging and molesting the Temple University employee at his suburban estate.

He was charged in late 2015, when a then-new prosecutor, District Attorney Kevin Steele, armed with newly unsealed evidence — Cosby’s damaging deposition from her lawsuit — arrested him days before the 12-year statute of limitations expired.

In 2005, prosecutor Bruce Castor had struck a deal with Cosby’s attorneys to not bring criminal charges.

The court has now ruled that Steele was obligated to stand by his predecessor’s promise, though there is no evidence that promise was ever put in writing.

“In light of these circumstances, the subsequent decision by successor D.A.s to prosecute Cosby violated Cosby’s due process rights,” Justice David Wecht wrote for the majority. “There is only one remedy that can completely restore Cosby to the status quo ante. He must be discharged, and any future prosecution on these particular charges must be barred.”

In May, Cosby was denied parole after refusing to participate in sex offender programs during his nearly three years in state prison. He has long said he would resist the treatment programs and refuse to acknowledge wrongdoing even if it means serving the full 10-year sentence.