The nation’s social media airwaves were in shock over news on Wednesday the Pennsylvania Supreme Court had vacated Bill Cosby’s sexual assault conviction, and the 83-year-old entertainer’s subsequent release from prison.

Cosby, 83, has served more than two years of a three- to 10-year sentence after being found guilty of drugging and violating Temple University sports administrator Andrea Constand at his suburban Philadelphia home in 2004. He was the first celebrity tried and convicted in the #MeToo era.

The former “Cosby Show” star was arrested in 2015, when a district attorney armed with newly unsealed evidence — the comic’s damaging deposition testimony in a lawsuit brought by Constand — brought charges against him days before the 12-year statute of limitations ran out.

But the Pennsylvania Supreme Court said that District Attorney Kevin Steele, who made the decision to arrest Cosby, was obligated to stand by his predecessor’s promise not to charge Cosby. There was no evidence that promise was ever put in writing.

Justice David Wecht, writing for a split court, said Cosby had relied on the former district attorney’s decision not to charge him when the comedian gave his potentially incriminating testimony in the Constand’s civil case.

The court called Cosby’s arrest “an affront to fundamental fairness, particularly when it results in a criminal prosecution that was forgone for more than a decade.”

The justices said that overturning the conviction, and barring any further prosecution, “is the only remedy that comports with society’s reasonable expectations of its elected prosecutors and our criminal justice system.”

“I am furious to hear this news,” actor Amber Tamblyn, a founder of Time’s Up, an advocacy group for victims of sexual assault, said in a Twitter post. “I personally know women who this man drugged and raped while unconscious. Shame on the court and this decision.”

Four judges formed the majority that ruled in Cosby’s favor, while three others dissented in whole or in part.

Even though Cosby was charged only with the assault on Constand, the trial judge allowed five other accusers to testify that they, too, were similarly victimized by Cosby in the 1980s. Prosecutors called them as witnesses to establish what they said was a pattern of criminal behavior on Cosby’s part.

The Pennsylvania Supreme Court justices voiced concern about what they saw as the judiciary’s increasing tendency to allow testimony that crosses the line into character attacks. State law allows “prior bad acts” testimony only in limited cases, including to show a crime pattern so specific it serves to identify the perpetrator.

The Associated Press contributed to this report.