NORRISTOWN, PA - FEBRUARY 03:  Bill Cosby arrives for the second day of hearings at the Montgomery County Courthouse February 3, 2016 in Norristown, Pennsylvania.  Cosby has been accused of sexually abusing several women.  (Photo by Ed Hille-Pool/Getty Images)
NORRISTOWN, PA - FEBRUARY 03: Bill Cosby arrives for the second day of hearings at the Montgomery County Courthouse February 3, 2016 in Norristown, Pennsylvania. Cosby has been accused of sexually abusing several women. (Photo by Ed Hille-Pool/Getty Images)
PHOTO: Ed Hille/Pool/Getty Images
Now playing
00:45
Bill Cosby sexual assault case allowed to move forward
Bill Cosby is taken away in handcuffs after he was sentenced to three-to 10-years for felony sexual assault on Tuesday, Sept. 25, 2018, in Norristown, Pa.  (Mark Makela/Pool Photo via AP)
Bill Cosby is taken away in handcuffs after he was sentenced to three-to 10-years for felony sexual assault on Tuesday, Sept. 25, 2018, in Norristown, Pa. (Mark Makela/Pool Photo via AP)
PHOTO: Mark Makela/Pool/AP
Now playing
01:12
See Bill Cosby leave court in handcuffs
NORRISTOWN, PA - SEPTEMBER 24: Actor and comedian Bill Cosby returns to the courtroom after a break with his spokesman Andrew Wyatt at the Montgomery County Courthouse, during his sexual assault trial sentencing in Norristown, Pennsylvania, U.S. September 24, 2018. (Photo by David Maialetti/Pool/Getty Images)
NORRISTOWN, PA - SEPTEMBER 24: Actor and comedian Bill Cosby returns to the courtroom after a break with his spokesman Andrew Wyatt at the Montgomery County Courthouse, during his sexual assault trial sentencing in Norristown, Pennsylvania, U.S. September 24, 2018. (Photo by David Maialetti/Pool/Getty Images)
PHOTO: David Maialetti/Pool/Getty Images
Now playing
00:48
Cosby sentenced to 3 to 10 years
Attorney Gloria Allred speaks about the sentencing of comedian Bill Cosby on 9/25.
Attorney Gloria Allred speaks about the sentencing of comedian Bill Cosby on 9/25.
PHOTO: WPVI
Now playing
00:59
Allred: Judgment day has come for Cosby
Montgomery County District Attorney Kevin Steele speaks after Bill Cosby sentencing.
Montgomery County District Attorney Kevin Steele speaks after Bill Cosby sentencing.
PHOTO: WPVI
Now playing
00:59
Prosecutor: Andrea Constand never waivered
Now playing
00:56
Cosby accuser gets emotional after sentencing
PHOTO: CNN
Now playing
02:06
Accuser: I saw violence in Bill Cosby
Actor and comedian Bill Cosby (C) comes out of the Courthouse after the verdict in the retrial of his sexual assault case at the Montgomery County Courthouse in Norristown, Pennsylvania on April 26, 2018. - Disgraced television icon Bill Cosby was convicted Thursday of sexual assault by a US jury -- losing a years-long legal battle that was made tougher at retrial as the first celebrity trial of the #MeToo era. (Photo by Dominick Reuter / AFP)        (Photo credit should read DOMINICK REUTER/AFP/Getty Images)
Actor and comedian Bill Cosby (C) comes out of the Courthouse after the verdict in the retrial of his sexual assault case at the Montgomery County Courthouse in Norristown, Pennsylvania on April 26, 2018. - Disgraced television icon Bill Cosby was convicted Thursday of sexual assault by a US jury -- losing a years-long legal battle that was made tougher at retrial as the first celebrity trial of the #MeToo era. (Photo by Dominick Reuter / AFP) (Photo credit should read DOMINICK REUTER/AFP/Getty Images)
PHOTO: DOMINICK REUTER/AFP/Getty Images
Now playing
01:50
Bill Cosby faces up to 30 years for assault
US comedian Bill Cosby leaves December 30, 2015 the Court House in Elkins Park, Pennsylvania after arraignment on charges of aggravated indecent assault. Cosby was arraigned over an incident that took place in 2004 -- the first criminal charge filed against the actor after dozens of women claimed abuse.AFP PHOTO/KENA BETANCUR / AFP / KENA BETANCUR        (Photo credit should read KENA BETANCUR/AFP/Getty Images)
US comedian Bill Cosby leaves December 30, 2015 the Court House in Elkins Park, Pennsylvania after arraignment on charges of aggravated indecent assault. Cosby was arraigned over an incident that took place in 2004 -- the first criminal charge filed against the actor after dozens of women claimed abuse.AFP PHOTO/KENA BETANCUR / AFP / KENA BETANCUR (Photo credit should read KENA BETANCUR/AFP/Getty Images)
PHOTO: KENA BETANCUR/AFP/AFP/Getty Images
Now playing
04:04
Cosby accuser: I'd like him to own up ...
PHOTO: NBC/"Dateline"
Now playing
01:05
Accuser: I forgave Bill Cosby to find peace
cosby juror
cosby juror
PHOTO: ABC
Now playing
01:09
Juror on what sealed Cosby's fate
Bill Cosby departs after a pretrial hearing in his sexual assault case at the Montgomery County Courthouse in Norristown, Pa., Tuesday, Aug. 22, 2017. Cosby
Bill Cosby departs after a pretrial hearing in his sexual assault case at the Montgomery County Courthouse in Norristown, Pa., Tuesday, Aug. 22, 2017. Cosby's retrial will be delayed as his new legal team gets up to speed on the case. (AP Photo/Matt Rourke)
PHOTO: Matt Rourke/AP/FILE
Now playing
02:13
Bill Cosby found guilty of sexual assault
Bill Cosby arrives for his sexual assault trial, Wednesday, April 25, 2018, at the Montgomery County Courthouse in Norristown, Pa. (AP Photo/Matt Slocum)
Bill Cosby arrives for his sexual assault trial, Wednesday, April 25, 2018, at the Montgomery County Courthouse in Norristown, Pa. (AP Photo/Matt Slocum)
PHOTO: Matt Slocum/AP
Now playing
02:40
Cosby had an emotional outburst in court
cosby verdict emotion
cosby verdict emotion
Now playing
01:31
Watch Cosby accusers react to verdict
PHOTO: Getty Images
Now playing
01:38
Highs and lows of Cosby's career

Story highlights

Spokesman for Bill Cosby says his lawyers think "the decision reached by the court was wrong"

Judge denies Bill Cosby's motion to dismiss case

Cosby's attorneys say decision not to prosecute in 2005 precludes current charges

(CNN) —  

The sexual assault case in Pennsylvania against Bill Cosby will go forward, a judge in Montgomery County ruled Wednesday.

Cosby’s lawyers had argued for two days during a pretrial hearing that a criminal case had been barred by a promise made in 2005 by then-District Attorney Bruce Castor never to prosecute the renowned entertainer.

The judge on Wednesday ruled “there was no basis to grant the relief requested” by Cosby.

A spokesman for Cosby’s legal team, Andrew Wyatt, told CNN his attorneys would appeal the judge’s determination. “The decision reached by the court was wrong,” he said.

Judge Steven O’Neill also ruled that prosecutor, newly elected District Attorney Kevin Steele, could stay on the case.

The case, in which former Temple University employee Andrea Constand accuses the TV star of assaulting her in his home in 2004, will go forward.

Cosby, who has not entered a plea, was charged December 30 with aggravated indecent assault against Constand, who went to authorities in 2005.

Bruce Castor, the Montgomery County district attorney at the time, did not file sexual assault charges against Cosby, citing “insufficient credible and admissible evidence.”

Cosby was charged in the case in December, 11 years after the state initially declined to prosecute.

In addition to denying the allegations, Cosby argues he’s being improperly prosecuted based on testimony he gave during a civil suit – testimony his defense says was given only because the state closed the criminal case in 2005.

But the district attorney’s office reopened the investigation based on “new evidence” that emerged from the unsealing of Cosby’s deposition in Constand’s civil suit.

Before court ended Wednesday, the judge scheduled a preliminary hearing on March 8.

Wednesday’s testimony

Lawyer John “Jack” P. Schmitt, part of a legal team that represented Cosby in 2005, testified Wednesday it was clear to him that a 2005 news release from Castor – one announcing the prosecutor wouldn’t file charges against Cosby in connection with a woman’s allegations – was a written and irrevocable agreement that the comedian would never be prosecuted.

“We certainly wouldn’t have let him (Cosby) sit for a deposition” if he were still subject to criminal prosecution in the case, Schmitt said.

Opinion: How strong is the criminal case against Bill Cosby?

In addition, Schmitt said, Cosby’s lead attorney in the Constand case, Walter Phillips, “got assurances from Mr. Castor that this was an irrevocable decision that he had made.” Phillips has since died.

On cross-examination, Schmitt acknowledged Wednesday there was no other document besides the news release saying that no charges would be filed.

The prosecution said the defense hadn’t proved its claim.

“They (the defense) are saying there is an explicit agreement, and they are saying this (press release) document is the explicit agreement and in that document itself says it will revisit the decision,” a prosecutor argued Wednesday.

Later in the day, the prosecution called Constand’s lawyer, Dolores Troiani, who said she was not aware in 2005 of any decision or agreement that the state would never prosecute Cosby.

“My understanding of the press release was that he was not going to prosecute at this time, but if there was additional information, he would change his mind,” she testified.

She said she didn’t hear until September 2015 of any assertion that Cosby could not ever be prosecuted.

On Tuesday, Castor testified he made the decision not to prosecute Cosby. He said he did so in part because he didn’t believe the case was strong enough for a conviction.

Castor also said he thought the move might help Constand successfully sue the entertainer. He essentially conceded that the only reason Cosby testified in Constand’s subsequent 2005 civil suit – the testimony that new prosecutors are now using to charge him – was because he took any potential prosecution off the table.

When Castor declined to prosecute in 2005, he said, Cosby couldn’t claim Fifth Amendment protection against self-incrimination in the civil suit.

But Castor told Cosby’s attorneys Tuesday: “I’m not on your team. I want them (the prosecutors who’ve charged Cosby) to win.”

Other legal matters for Cosby

Also Tuesday in a separate case, a woman dropped a civil suit against the legendary comedian in a California court. Chloe Goins, now 24, had alleged Cosby sexually assaulted her at the Playboy Mansion in 2008.

She filed a court document allowing the suit to be dismissed.

Last month, a prosecutor in Los Angeles County declined to pursue a criminal case, saying evidence was insufficient to prove a crime was committed. Investigators learned Cosby was in New York the weekend of the event at which Goins accused Cosby of assaulting her.

Criminal case in Pennsylvania

According to an affidavit, Constand alleged Cosby drugged and sexually assaulted her in his Pennsylvania home in early 2004 after inviting her there to discuss her professional future.

Constand, a former director of operations for Temple University’s women’s basketball team, met Cosby in 2002 when, according to prosecution documents, she believed he sought her out to be a “mentor” and “sincere friend.”

Constand’s civil suit alleged battery, sexual assault and intentional infliction of emotional distress.

The suit was settled in 2006 with a confidential settlement agreement but not before a judge compelled Cosby to answer questions under oath.

That deposition was sealed for the last decade, but a federal judge unsealed parts of it last summer.

The district attorney’s office then cited “new evidence” from the deposition to reopen the case and brought the charges against Cosby.

That new evidence, according to prosecutors, centers on a question from Constand’s attorney Dolores Troiani and Cosby’s response during the sworn testimony:

Q. “When you got the Quaaludes, was it in your mind that you were going to use these Quaaludes for young women that you wanted to have sex with?”

A. “Yes.”

Cosby later stated in the deposition he was only referring to one unnamed woman.

According to Cosby’s 2005 deposition testimony, he admitted sexual contact with Constand but said it was consensual.

Castor: I had bound Pennsylvania to my decision

On Tuesday, Castor said he warned his successor in 2015 – then-District Attorney Risa Vetri Ferman – that the case had been “put to rest.”

Castor testified that when he heard speculation last year that Ferman might charge Cosby, he reminded her by email that he’d already committed the state not to prosecute the comedian.

“I knew I had bound the commonwealth as a representative of the sovereign,” Castor said.

He further explained to Cosby’s attorneys Tuesday why he didn’t pursue charges. He said:

• There were inconsistencies in Constand’s statements to police. “Within days, she changed the day when it happened from March back to January ‘04.”

• Those inconsistencies “would affect her credibility at trial.”

• Constand contacted a civil lawyer before taking her allegations to police, which also hurt her credibility. Castor said that Cosby’s lawyer – Walter Phillips – told him that Constand and her mother were trying to get money from Cosby in exchange for not going to police.

• “Making Mr. Cosby pay money to Ms. Constand (through a civil suit) was the best I was going to be able to set the stage for.”

But Castor said he believed Constand.

“What I think and what is provable in a courtroom is two different things,” Castor said. “… What I think is that Andrea Constand was inappropriately touched by Mr. Cosby.”

Steele, the new district attorney, has argued a non-prosecution agreement never existed, saying in legal filings his office has no such documentation and can’t find anyone who does.

Cosby has yet to have his preliminary hearing and formal arraignment in the case.

CNN’s Aaron Cooper reported from Norristown; CNN’s Jason Hanna and Steve Almasy wrote from Atlanta. CNN’s Jean Casarez, Steve Forrest and Dottie Evans contributed to this report.