Bill Cosby took a big legal hit today with a Pennsylvania judge refusing to toss out criminal charges against the much accused actor stemming from an alleged 2004 sexual assault.

After an opening day on Tuesday that mostly saw a former District Attorney on the stand detailing the self-described binding decision he made a decade ago not to prosecute Bill Cosby, the comedian was back in court early Wednesday. Accused by more than 50 women of sexually assaulting them over the years, The Cosby Show actor and his lawyers were in Norristown, PA trying unsuccessfully to get the only criminal charges actually ever filed against him dismissed based on the verbal immunity determination Bruce Castor granted in 2005.

“It was a secret agreement that permits a wealthy defendant to buy his way out of a criminal case,” said current Montgomery County District Attorney Kevin Steele today, urging the judge to ignore Castor’s actions and let the criminal matter go forward. “There is no legal authority allowing a District Attorney to unilaterally confer transactional immunity on a defendant,” Steele added in the pre-trial hearing. “A promise is a promise,” asserted Cosby attorney Christopher Tayback in response. “The current District Attorney is trying to get out from underneath that promise,” the L.A.-based lawyer told the court. Calling the deal “revisionist history,” Steele said later in the day that Castor’s “credibility is out the window at this point.”

Though Wednesday went long, Judge Steven O’Neill had indicated on Tuesday that he would rule on the motion today. The stakes are no joke for the now disgraced 78-year old actor-comedian – if convicted on the three felony charges of second-degree aggravated indecent assault, Cosby could get up to 10 years in prison and pay a $25,000 fine. Going immediately forward, Cosby’s lawyers are expected to try tonight to get some traction on their motion to have Steele disqualified from the case. In the slightly more long term, a preliminary hearing is now scheduled in the criminal charges for March 8 in what is sure to be a very long road to a trial – if that ever actually happens.

A laughing Cosby arrived at the suburban Philadelphia courthouse around 9:15 AM ET this morning for the 9:30 AM pre-trial hearing. Day 2 of the East Coast pre-trial hearing comes one day after another Cosby accuser dropped her case on the West Coast while another accuser was granted a second deposition of the actor in her suit by a California judge. Soon after what was essentially a first round of closing arguments, Judge O’Neill went into chambers and granted a recess around 10 AM PT. Cosby, the lawyers and the press in the courtroom and closed-circuit camera supplied overflow room returned about 45 minutes later for an afternoon session with more witnesses. At approximately 2:20 PM PT, an evening recess was called and the Judge returned to his chambers again to finalize today’s ruling.

Newly elected D.A. Steele filed the criminal charges against Cosby late last year just before the state statute of limitations expired on Andrea Constand’s case. Bill Cosby mug shot.Facing several other cases around the nation from other accusers, including former America’s Next Top Model judge Janice Dickinson’s defamation claims in Los Angeles, Cosby was arraigned and released on bail of $1 million December 30 without entering a plea. Very soon his legal team filed the petition for dismissal based on Castor’s protective deal.

Steele’s office has said that they are not bound by the unusual so-called no prosecution agreement because it was never put in writing nor followed the set procedure for such arrangements – and that is why everyone is in court Wednesday.

The earlier part of today saw longtime Cosby lawyer John P. Schmitt take the stand under questioning from Steele. Schmitt told the D.A. and the court that he too had known about the 2005 deal from Castor that the actor could never be prosecuted so he would speak freely in depositions in a civil case from Constand. Later on Wednesday, Dolores Troiani, who was Constand’s attorney in her civil case, told Steele that she never was told about a no-prosecution deal for Cosby by ex-D.A. Castor, nor his office or the actor’s lawyers. “When she first approached Mr. Castor’s office we were not confident he would prosecute because he was running for some sort of office and he would not want to alienate those fans of Dr. Huxtable,” Troiani said in court referencing the once massively popular Cosby character from his top-rated 1980s sitcom.

The explosive unsealing last summer of portions of the 2005 deposition by Cosby in the civil case by the former director of operations for Temple University’s women’s basketball team divulged that the actor did have prescriptions for Quaaludes in the 1970s that he planned to use to have sex with women. Originally speaking to police in her native Canada, Constand claimed that Cosby sexually assaulted her in January 2004 in his Philly mansion after drugging her with pills.

The controversial unsealing led to a deluge of new cases being filed last year against Cosby as the decade-old deposition fitted the description of behavior and methods that many had claimed the actor had also used against them. Today in court, Judge O’Neill weigh whether Cosby’s deposition was the core of the new charges or if other statements that both the actor and Constand made, play a role as well.

Still, as Castor’s testimony revealed yesterday, the ex-D.A. felt back in early 2005 there was “insufficient, credible and admissible evidence upon which any charge against Mr. Cosby related to the Constand incident could be proven beyond reasonable doubt.” Later in the day, Castor stated that despite that he thought that “Andrea Constand was inappropriately touched by Mr. Cosby” and he wanted her side to “win.”

Cosby and lawyers feb 2 court drawing Monique Pressley, Brian McMonagle, Christopher Taybeck, Bill CosbyEarlier, Cosby’s lawyers, the prosecution and the packed courtroom listen as Castor explained he did not seek “any quid pro quo” from Cosby’s lawyers in 2005. However, Castor added, he went for the in-perpetuity no-prosecution deal so he could make sure Cosby didn’t claim the fifth amendment in any civil action the ex-Temple University employee pursued. He informed the court that this was within his understanding of his “sovereign” state power as D.A. and that he made the decision known at the time to now deceased Cosby lawyer Walter M. Phillips and in a press release sent out at the time.

“My choices were to leave the case open and hope it got better,” Castor said on Tuesday afternoon. “Or definitively close the case and allow the civil court to provide redress to Ms. Constand.” Though critical of the way Canadian-born Constand initially started her claims against Cosby of drugging and assaulting her in 2004, Castor was candid about what he wanted to come out of any potential settlement –  “I was hopeful that I had made Ms. Constand a millionaire.”

Constand’s civil case against Cosby did eventually result in a settlement in 2006.

Mark Dent & Chris Krewson contributed to this report.