Actor and comedian Bill Cosby arrives for a court appearance in Norristown, Pennsylvania, Feb. 3, 2016.
Actor and comedian Bill Cosby arrives for a court appearance in Norristown, Pennsylvania, Feb. 3, 2016.

A Pennsylvania judge late Wednesday dismissed defense efforts to have criminal sexual assault charges against comedian Bill Cosby thrown out, ruling that his trial can proceed.

Cosby's lawyers argued that a former district attorney granted Cosby immunity from prosecution in 2005 so he could use Cosby's testimony in a civil suit by an alleged victim.

"In this case, the prosecution should be stopped in its tracks," lawyer Chris Tayback told the court. "Really, what we're talking about here is honoring a commitment."

But there was nothing in writing about immunity, and the judge agreed with prosecutors that the criminal case against Cosby can go on.

"A secret agreement that allows a wealthy defendant to try to buy his way out of a criminal case isn't right," current Montgomery County District Attorney Kevin Steele argued.

Case against Cosby

Prosecutors decided in late December to charge Cosby with sexually assaulting Andrea Constand in his Philadelphia home in 2004 after allegedly giving her wine and pills that left her unable to fight back. He faces 10 years in prison and a $25,000 fine if convicted.

Cosby and his lawyers have consistently denied charges of sexual misconduct.

Constand is a former basketball team manager at Temple University, Cosby's alma mater. She testified in the civil suit that she approached the comedian in 2004 for career advice. She says Cosby invited her to his home, gave her wine and urged her to take three blue pills.

Constand says she soon found herself unable to move or speak while Cosby fondled her.

Constand settled the civil suit against Cosby in 2006.

Cosby's testimony

Cosby testified that he and Constand had consensual sex. He admitted obtaining quaalude pills to give to women with whom he wanted to have sex, but insisted the encounters he had with women were consensual.

More than 50 women say Cosby sexually assaulted them in incidents dating back to the 1960s when he first emerged as a comedy star, but only the Constand case has come to trial.

The allegations have destroyed Cosby's image as the good-natured storyteller and family man he developed over five decades as a major television comedy star.

The 1980s series The Cosby Show, in which he played a successful doctor, was television's highest-rated program for a number of years, but is scarcely seen in rebroadcasts.