US comedian Bill Cosby has left prison hours after his sexual assault conviction was overturned by Pennsylvania’s Supreme Court.
The judges said there had been a “process violation” by the prosecution but admitted their ruling was unusual.
Mr Cosby, 83, had served more than two years of a three to 10-year sentence at a state prison near Philadelphia.
In 2018 he was found guilty of drugging and molesting ex-basketball player Andrea Constand.
Cosby is best known for starring in the 1980s TV series The Cosby Show and was once known as “America’s Dad”.
Actor Phylicia Rashad, who played his wife in the sitcom wrote on Twitter: “A terrible wrong is being righted- a miscarriage of justice is corrected!”
Dozens of women had publically accused him of sexual assault, although he was only tried criminally for the incident against Andrea Constand. His conviction in 2018 was widely seen as a landmark moment in the #MeToo movement.
But now, Pennsylvania’s highest court has found there was a “process violation” because Mr Cosby’s lawyers had made an agreement with a previous state prosecutor that he would not be charged in the case.
However in 2015 a new prosecutor filed charges after testimony from a civil lawsuit brought by Andrea Constand against the actor was revealed.
“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”, the 79-page finding reads.
“We do not dispute that this remedy is both severe and rare. But it is warranted here.”
In their decision, the judges also found that testimony from accusers unrelated to the case had tainted the trial.
In a first trial, which failed to reach a verdict in 2017, one accuser was called to testify. However in the second trial five women were brought to testify about their experiences with Mr Cosby in the 1980s.
The judges found it was not acceptable to hear testimony from the women who were not directly related to the case, although an appeals court had said it showed a pattern of abuse.
“He was found guilty by a jury and now goes free on a procedural issue that is irrelevant to the facts of the crime,” state prosecutor Kevin Steele said in a statement.
“My hope is that this decision will not dampen the reporting of sexual assaults by victims… We still believe that no one is above the law – including those who are rich, famous and powerful.”