Bill Cosby was released from prison on Wednesday immediately following a Pennsylvania Supreme Court ruling that he did not receive a fair trial.

Cosby walked out of the State Correctional Institution Phoenix in Montgomery County, Pennsylvania.

In a ruling released Wednesday, the state Supreme Court concluded that Cosby’s prosecution should never have occurred due to a deal the comedian cut with former Montgomery County prosecutor Bruce Castor, who agreed not to criminally prosecute Cosby if he agreed to give a deposition in a civil case brought against him by Andrea Constand.

Cosby was sentenced in September 2018 to 3 to 10 years in state prison for allegedly drugging and sexually assaulting former Temple University employee Andrea Constand in 2004. Cosby has served a little less than two years of his sentence.

Cosby was picked up from prison by his publicist.