The Pennsylvania Supreme Court on Wednesday threw out Bill Cosby’s 2018 sexual assault conviction, leading to his release from prison, ruling that the 83-year-old comic once known as “America’s Dad” had been denied due process based on a former prosecutor’s decade-old promise not to charge him.

Cosby had already served more than two years of a three-to-10-year sentence after he was found guilty of drugging and assaulting Temple University employee Andrea Constand in 2004, a case that served as the first high-profile celebrity conviction of the #MeToo era.

» READ MORE: Bill Cosby released from prison after Pa. Supreme Court overturns sexual assault conviction

But a majority of judges on Pennsylvania’s highest court Wednesday ruled that Montgomery County District Attorney Kevin R. Steele — who brought charges against the former Cosby Show star in 2015 based on his deposition in a lawsuit — was legally bound by a previous prosecutor’s promise not to criminally charge Cosby. Evidently it was based on that pledge, they ruled, that the comedian spoke freely and made potentially self-incriminating claims in his civil suit testimony.

» READ MORE: Read the Pa. Supreme Court’s opinion in the Bill Cosby trial

Here are the key points to know about the latest developments.

Bruce Castor and the 2005 agreement

The opinion centers on the words of former Montgomery County District Attorney Bruce L. Castor, who earlier this year made headlines after defending former President Donald Trump at his Senate impeachment trial.

Constand, a Temple sports administrator, first reported the alleged assault to Castor in 2005. Castor declined to file charges against Cosby, saying he was not sure her allegations would hold up in criminal court. Instead, he said he struck a deal with Cosby not to prosecute, so that the comedian would testify in civil court in a lawsuit Constand filed against him.

There is no evidence Castor’s non-prosecution agreement was ever put in writing. In 2006, Cosby settled with Constand for nearly $3.4 million.

» READ MORE: Bill Cosby’s release from prison once again shines a light on Bruce Castor. And Castor feels ‘vindicated.’

» READ MORE: A timeline of the Cosby case

Conviction overturned, no retrial

The opinion says that it was due to Castor’s agreement not to charge Cosby that the comedian testified in Constand’s lawsuit, saying under oath he would offer quaaludes to women he wanted to have sex with.

But after prosecutors reopened the criminal case against Cosby in 2015 — days before the 12-year statute of limitations expired and amid a flood of new accusations from women across the country — excerpts from Cosby’s civil suit deposition were ultimately used against him in trial, in what state Supreme Court justices said was a violation of his constitutional rights.

» READ MORE: From 2018: Using Bill Cosby's own words, prosecutors near end of their case against comedy icon

The ruling also bars Cosby from being retried on the same charges.

Home from prison

Within hours of the high court’s opinion, Cosby had been released from prison and stood with attorneys outside his home in Elkins Park. He did not speak, but wore a Central High School T-shirt while smiling. Some fans and a lone protester gathered with reporters outside the house.

He later tweeted, thanking his fans, supporters and friends, and the “Pennsylvania Supreme Court for upholding the rule of law.”

» READ MORE: Bill Cosby returns home after being released from prison

Accusers and advocates say it ‘just doesn’t seem right’

The court’s decision came as a shock to his dozens of accusers and activists who saw his imprisonment as a win for the #MeToo movement.

“I thought this was done,” said Autumn Burns, 73, who had publicly accused Cosby of raping her in the 1970s. “It just doesn’t seem right.”

But activists and advocates were quick to point out that the high court’s decision was “on technical grounds” and did not challenge the adequacy of the evidence against Cosby.

» READ MORE: Bill Cosby’s release leaves accusers dismayed, but women’s advocates say no court can erase their ‘courage and resolve’

» READ MORE: Where to find sexual assault support and counseling resources in the Philadelphia region