NORRISTOWN: A US judge paved the way Wednesday for disgraced TV legend Bill Cosby to stand trial for the first time on a criminal sexual assault charge, throwing out an attempt by his lawyers to dismiss the case.

Dozens of women have come forward to accuse the 78-year-old Cosby of abuse in allegations spanning four decades, but the vast majority have expired under statues of limitations.

The megastar turned pariah spent two days in court in Norristown, just outside Philadelphia, as his lawyers disputed the legality of the case, which dates back to 2004 and was settled in 2006 by a civil suit.

In a deposition Cosby gave as part of the civil suit, he admitted giving the woman, Andrea Constand, a pill but said all relations with her were consensual and accused her of lying about the assault.

Prosecutors in Montgomery County reopened the case last year, claiming that new evidence came to light in July. Cosby posted bail of $1 million on Dec. 30.

Cosby’s legal team argued that violated a 2005 agreement that he would never be prosecuted over the allegation of assault made by Constand, a former employee of Temple University in Philadelphia.

Constand says Cosby forced himself on her at his suburban Philadelphia home in 2004. Prosecutors say he urged her to take pills, leaving her unable to resist as he made his move on her.

If found guilty, Cosby — who has surrendered his passport to the court but has yet to enter a plea to the criminal charge — could face up to 10 years in prison and a $25,000 fine.