NORRISTOWN, Pennsylvania (WPVI) -- Pennsylvania's highest court threw out Bill Cosby's sexual assault conviction and released him from prison Wednesday in a stunning reversal of fortune for the comedian once known as "America's Dad," ruling that the prosecutor who brought the case was bound by his predecessor's agreement not to charge Cosby.
Cosby, 83, flashed the V-for-victory sign to a helicopter overhead as he trudged into his suburban Philadelphia home after serving nearly three years of a three- to 10-year sentence for drugging and violating Temple University sports administrator Andrea Constand in 2004.
"In 2005, I had come to the conclusion that there was not enough evidence to arrest and convict him," said former Montgomery County District Attorney Bruce Castor in an interview with Action News.
He also explained why he made a promise to Cosby that would never happen.
"The choices became do nothing or do something. I chose to do something," said Castor.
The former district attorney says it was in that promise that Cosby would be forced to participate in a deposition where he would be stripped of his ability to plead the 5th Amendment, and ultimately provide Andrea Constand's attorneys the ammo for a successful civil suit.
It's noted in the Pennsylvania Supreme Court's opinion that "Cosby even confessed that, in the past, he had provided Quaaludes -not Benadryl- to other women with whom he wanted to have sexual intercourse."
Castor says it was a chess game that worked exactly how he wanted.
"If the civil lawyers played the pieces right, they would get Cosby deposed. He would say things that were incriminating and they would then use that to leverage a settlement worth millions of dollars. Well that's exactly what happened," said Castor.
But he also says it was made very clear to any future Montgomery County District Attorney, the statements made by Cosby in his deposition could never be used as evidence in a criminal case.
"The Supreme Court cites my memo, my private memo to them, saying 'don't do this because you're going to have a problem with using the deposition testimony' because that only existed because I said I wasn't going to prosecute Cosby," said Castor.
In response, current Montgomery County Kevin Steele, who prosecuted Cosby, released a statement Wednesday saying, "He was found guilty by a jury and now goes free on a procedural issue that is irrelevant to the facts of the crime. I want to commend Cosby's victim Andrea Constand for her bravery in coming forward and remaining steadfast throughout this long ordeal, as well as all of the other women who have shared similar experiences."
"Whether Montgomery County has liability, whether Kevin Steele has a disciplinary liability, remains to be seen," said Castor.
Castor also says it's possible Cosby could sue Montgomery County for how this was handled.
The court called Cosby's subsequent arrest "an affront to fundamental fairness, particularly when it results in a criminal prosecution that was forgone for more than a decade." It said justice and "fair play and decency" require that the district attorney's office stand by the decision of the previous DA.
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."
Cosby was promptly set free from the state prison in suburban Montgomery County and driven home.
"What we saw today was justice, justice for all Americans," said a Cosby spokesperson, Andrew Wyatt. "Mr. Cosby's conviction being overturned is for the world and all Americans who are being treated unfairly by the judicial system and some bad officers."
Bonjean said Cosby was "extremely happy to be home" and "looks forward to reuniting with his wife and children." Several supporters outside yelled, "Hey, hey, hey!" - the catchphrase of Cosby's animated Fat Albert character - which brought a smile from him.
He later tweeted an old photo of himself with his fist raised and eyes closed, with the caption: "I have never changed my stance nor my story. I have always maintained my innocence. Thank you to all my fans, supporters and friends who stood by me through this ordeal. Special thanks to the Pennsylvania Supreme Court for upholding the rules of law."
The Associated Press contributed to this report.