Cosby's lawyers' relief request has been denied, and the 78-year-old entertainer could potentially be facing a criminal trial.
An attempt made by Bill Cosby's lawyers to have an aggravated indecent assault charge dismissed has been rejected by Judge Steven O'Neill, which means the 78-year-old comedian could potentially face trial.
Attorneys for Cosby spent the last two days arguing that former Montgomery County District Attorney Bruce Castor made an oral agreement with Cosby's lawyer over 10 years ago. The agreement stated that Castor would not prosecute the entertainer regarding sexual assault claims leveled against him by a former Temple University employee Andrea Constand in 2005.
WATCH: Bill Cosby Moves to Dismiss the Criminal Charge Against Him
On Wednesday, O'Neill ruled that he found "no basis to grant the relief request" presented by Cosby's lawyers, ABC News reports.
Current Montgomery County DA Kevin Steele argued against the relief request, asserting that an oral immunity deal is irrelevant and unenforceable, and that such a deal should have been put in writing and agreed to by a judge at the time.
Castor testified that he felt Constand's actions in 2005, including contacting a lawyer before going to police -- didn't reflect those of a sexual assault victim and "created a credibility issue."
WATCH: Bill Cosby Appears in Court, Former D.A. Explains Why He Didn't Prosecute in 2005
Castor admitted that he believed Constand was telling the truth, but that she had waited too long to come forward with her claims.
Attorney Jack Schmitt, Cosby's longtime legal adviser, testified on Wednesday that he would not have had Cosby give a deposition in Constand's 2005 civil suit if he thought Castor's oral non-prosecution agreement wouldn't be honored in the future, ABC News reports.
Following Judge O'Neill's ruling, a representative for Cosby released a statement to ET slamming the decision.
"After two days' presentation of evidence and law in support of Mr. Cosby's Habeas Petition, the decision reached by the court was wrong," the statement reads. "We will appeal."
MORE: Bill Cosby's Accusers: A Timeline of Alleged Sexual Assault Claims (Updated)
Attorney Gloria Allred, who represents a number of other women who have accused Cosby of sexual assault over the last year, released a statement praising Judge O'Neill's ruling.
"The judge clearly made the right decision on both the facts and the law when he decided to allow the criminal case against Bill Cosby to move forward," Allred expressed in her prepared statement. "Now Mr. Cosby will have to face the serious charges of aggravated indecent sexual assault in a criminal court."
"This motion by Mr. Cosby to have his criminal case dismissed was just the latest in a long string of unsuccessful legal maneuvers by him to try to avoid having a jury decide his guilt or innocence," Allred continued. "Once again he has failed and he will now have to face at least one of his accusers in a court of law."
WATCH: See Bill Cosby's Mug Shot After Posting $1 Million Bail for Sexual Assault Charge
Cosby was charged in December for the alleged incident that is said to have taken place in January 2004. Constand alleges that Cosby drugged and violated her at his mansion in Elkins Park, Pennsylvania. Cosby has denied any wrongdoing.
The charge against Cosby carries a maximum penalty of 5-10 years in prison and a $25,000 fine.
For more on the attempts made by Cosby's legal team to get the sexual assault charge dismissed, watch the video below.