Bill Cosby's lawyers attacked the criminal charges lodged against him as "illegal," saying they violate a prosecutor's pledge that he would never be charged over a 2004 sexual encounter with a Temple University employee.

That promise led Cosby to testify in a related civil lawsuit without invoking his Fifth Amendment rights, the lawyers said in a court filing Monday. Yet, a decade later, a new prosecutor called the newly released deposition testimony a key piece of evidence that fueled his decision to arrest Cosby last month.

Cosby lawyer Brian McMonagle wrote in the defense motion that the state agreed Cosby would never be prosecuted with respect to the allegations of sexual assault made by the Temple employee, Andrea Constand.

"Now, to fulfill campaign promises, the newly-elected District Attorney has repudiated the agreement and has based these criminal charges on this very testimony," McMonagle wrote.

The motion lays out the defense's plan of attack for the upcoming Feb. 2 preliminary hearing and asks for District Attorney Kevin Steele's office to be disqualified if the case isn't thrown out. It says there are several flaws with the prosecution case, including the "inexcusable," decade-long delay in making an arrest. Since then, Cosby's vision has deteriorated to the point he can no longer identify witnesses and accusers, and a lawyer who helped negotiate the "non-prosecution agreement" with former district attorney Bruce Castor, Walter M. Phillips Jr., has died, the motion said.

Steele last fall had attacked Castor, a political opponent, over his 2005 handling of the case, running an ad that said: "Bruce Castor had an opportunity to bring charges, and he failed to do so."

Cosby's lawyers called the political campaign references to the case "wildly improper."

"A citizen's constitutional rights cannot be thwarted by politically motivated prosecutors willing to break agreements made by their predecessors," McMonagle wrote. "The commonwealth's agreement must be enforced, and the charges dismissed."

Steele, then the top deputy prosecutor, announced the charges on Dec. 30, days ahead of the 12-year deadline to file charges. He took office as district attorney on Jan. 4.

In a text message late Monday, he said he had not seen the court filing and could not comment on it.

Cosby settled the civil lawsuit with Constand for an undisclosed sum in 2006 after giving four days of deposition testimony.

Constand is now a massage therapist in Toronto. Her lawyer has said she is grateful to Steele's office for its work and is ready to testify against Cosby in criminal court.

Several women, mostly from the worlds of modeling, acting or other entertainment fields, have accused Cosby of drugging and molesting them. Cosby, who played Dr. Cliff Huxtable on "The Cosby Show" from 1984 to 1992 and has been married for decades, has denied any wrongdoing.