Bill Cosby
Bill Cosby got some bad news in court.REUTERS/Lucas Jackson

Despite comedian Bill Cosby's claim that he was handed a get-out-of-jail-free card from a Pennsylvania prosecutor, a judge has ruled that the sexual assault case currently filed against him should go forward.

Cosby has been charged with aggravated indecent assault on Temple University basketball team employee Andrea Constand, now 44. She said Cosby plied her with alcohol and drugs in his home just outside Philadelphia before raping her in 2004.

The judge's refused to dismiss the case against Cosby opens the way for the first criminal prosecution of the once-respected actor who has denied sexual assault accusations by more than 50 women. Cosby's attorneys had argued that their client could not be prosecuted because of an agreement with a former Montgomery Country district attorney more than a decade ago over a lawsuit filed by Constand.

Former District Attorney Bruce Castor testified at the hearing that he agreed he would not file charges against Cosby if the comedian agreed to a deposition in the suit. "I was hopeful that I had made Ms. Constand a millionaire," testified Castor, who said he was hoping to help make life easier for Constand, reported NBC News.

There was no written agreement from Castor concerning the agreement, and Constand said she was unaware that such a discussion took place. Castor also testified that phone calls made by Cosby to Constand and recorded by her "could be construed as incriminating," but that he didn't believe they would be admissible in a court case.

In fact, he said the recordings were evidence that Constand and her mother "had committed a felony" because they represented an "illegal wiretap." But he also said he was convinced Cosby had "inappropriately touched" Constand and that he "wanted to see Mr. Cosby punished," but he didn't think he could win a criminal case.

Current Montgomery County District Attorney Kevin Steele argued in court that the deal wasn't legitimate. "A secret agreement that permits a wealthy defendant to buy his way out of a criminal case isn't right," he said

Judge Steven O'Neill agreed, ruling: "I hereby find no basis to grant the relief requested." The 78-year-old comedian sat silent and stone-faced when the judge announced his decision. Cosby could face up to 10 years in prison if convicted in the case.

Cosby has denied any wrongdoing ever against any of the scores of women who have accused him of asssault. He admitted he gave Constand alcohol and drugs but insisted the passed-out sex was consensual.