The Pennsylvania Supreme Court ruling that led to Bill Cosby’s release from prison Wednesday focused on a purported promise made by a man who is once again back in the spotlight: Bruce L. Castor Jr.

In overturning Cosby’s 2018 sexual assault conviction, the court said Montgomery County District Attorney Kevin R. Steele was legally bound by Castor’s decision not to prosecute Cosby more than a decade earlier when he was DA — and therefore should not have brought charges when new evidence surfaced.

“When a prosecutor makes an unconditional promise of non-prosecution, and when the defendant relies upon that guarantee to the detriment of his constitutional right not to testify, the principle of fundamental fairness that undergirds due process of law in our criminal justice system demands that the promise be enforced,” Justice David N. Wecht wrote in the majority opinion.

Castor’s starring role in Cosby’s release marked the second time this year that the firebrand former county commissioner found the glare of the national spotlight he is known to love, after fading in Pennsylvania politics when his brief stint as acting state attorney general ended in 2016. Castor first burst back into the news in January when he joined the legal team that defended former President Donald Trump at his second impeachment trial — complete with a widely ridiculed opening argument.

Castor has insisted that his 2005 promise not to prosecute Cosby, which was never formally memorialized and became a key issue in pretrial proceedings after Cosby was charged in 2015, was nevertheless binding.

On Wednesday, Castor said the court had vindicated him.

“After all, I am a lawyer and whenever the Pennsylvania Supreme Court agrees with a lawyer’s legal reasoning is a good day,” Castor told The Inquirer shortly after Cosby’s release.

“I feel vindicated that my decision process was correct and Justice Wecht certainly made clear that the Supreme Court not only understood my thinking but agreed with it,” Castor added.

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

But Wecht’s opinion noted that Castor’s comments about the agreement have been contradictory at times.

The court’s rationale for overturning Cosby’s conviction hinged not as much on Castor’s promise as it did on Cosby’s reliance on that promise. Cosby went on to testify in a deposition for accuser Andrea Constand’s lawsuit against him, and his lawyers argued that he only did so because he had been assured he would not be prosecuted.

That deposition later featured in Cosby’s criminal trial.

“The former district attorney may have equivocated or contradicted himself years later with regard to how he endeavored to achieve that result, but there has never been any question as to what he intended to achieve,” Wecht wrote of Castor’s agreement not to prosecute Cosby in exchange for his testimony in the civil suit.

And a dissenting opinion by Justice Kevin M. Dougherty was withering in its assessment of the deal Castor made with Cosby, saying that “Castor’s view is wrong as a matter of law” and that it’s “dangerous to even implicitly suggest otherwise.”

Pennsylvania political watchers who have long tracked Castor’s career weren’t surprised to see him back at center stage Wednesday. Castor long harbored statewide political ambitions, only to see them flame out as he burned bridges within his own party.

“Controversy seems to have a way of finding him,” said Brian Miles, a longtime Castor friend.

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

Castor on Wednesday blamed Montgomery County politics for tainting earlier court rulings on his non-prosecution deal. Common Pleas Court Judge Steven T. O’Neill, who presided over Cosby’s trials and ruled in 2016 that Castor’s promise was not binding, had previously run unsuccessfully against Castor for DA. And Steele, who ultimately prosecuted Cosby after Castor didn’t, defeated Castor for the job in 2015.

“I thought the Supreme Court would reverse the conviction,” Castor said. “... Once it got out of Montgomery County and was free of Montgomery County politics, it was obviously the right thing to do.”

Noting that the court had ordered Cosby’s release and barred any future retrials, Castor equated the ruling to “the death penalty for the prosecution.”

Steele, for his part, emphasized in a statement that Cosby was released “on a procedural issue that is irrelevant to the facts of the crime,” and said he hopes the outcome doesn’t make victims more hesitant to report sexual assaults.

Constand’s lawyers, Dolores Troiani and Bebe Kivitz, have long criticized Castor for his handling of the investigation in 2005 and for announcing his decision not to prosecute without first informing them.

They said Wednesday in a joint statement with Constand that the state Supreme Court had found that Castor’s promise “was not a formal immunity agreement and constituted at best a unilateral exercise of prosecutorial discretion.”

“We were not consulted or asked our thoughts by Mr. Castor concerning any agreements concerning immunity or anything, and we were not made aware if there were any such discussions,” they said.

Constand sued Castor for defamation in 2015, as the District Attorney’s Office was preparing to charge Cosby and Castor was speaking out about the case while running against Steele to get his old job back. Castor then filed his own suit against Constand in 2017, which was dismissed. Constand’s lawsuit against Castor was settled in 2019.

» READ MORE: Inside Trump’s Philly impeachment team: Confusion, conflict, and threats to quit amid ‘out-and-out partisan war’

Jennifer Storm, the former Pennsylvania victim advocate, said she hopes other prosecutors still conclude that Castor’s 2005 decision was incorrect.

“I really hope prosecutors look at this and say Bruce Castor made a bad decision, and a victim’s voice is evidence enough to prosecute,” she said. “If that means the only evidence you have is the victim’s voice, that is evidence to charge and prosecute.”

Castor, who had previously said he was rooting for the prosecution and congratulated Steele on the conviction, was more focused Wednesday on the court’s decision about his non-prosecution deal than he was on Cosby’s release from prison.

“The rules weren’t followed, the Supreme Court has spoken,” he said, “and I don’t feel any regret that he got out and I don’t feel any satisfaction that he got out.”

Staff writer Anna Orso contributed to this article.