Comedian Bill Cosby is seeking to derail Pennsylvania prosecutors' effort to make him stand trial on sexual assault charges, contending that a deal reached over a decade ago gave him immunity from prosecution.
An entertainer who built a career on family-friendly comedy, Cosby now faces accusations from more than 50 women that he sexually assaulted them, often after plying them with drugs and alcohol, in a series of attacks dating to the 1960s.
Prosecutors late last year charged Cosby, 78, with sexually assaulting Andrea Constand, a former basketball coach at his alma mater Temple University, just days before the statue of limitations to bring charges ran out.
Constand's allegations are the only ones to have resulted in criminal charges against Cosby, although he also faces a series of civil lawsuits related to alleged rapes.
Cosby has long denied wrongdoing, and his lawyers have asked the judge to dismiss the Constand case.
Former Montgomery County District Attorney Bruce Castor testified on Tuesday that he decided in 2005 not to bring charges over the Constand allegations.
A 2005 press release in which Castor said Cosby would never be prosecuted was read out in court, with defence lawyers contending it represented a non-prosecution agreement.
Castor, called to testify at a pretrial hearing by Cosby's lawyers, said he feared Constand's credibility as a witness could have been undermined because she waited a year to file her criminal complaint against Cosby and explored a civil lawsuit.
He said that he believed Constand's allegations but had worried that a jury would not.
"Making Mr Cosby pay money to Ms Constand was the best I would be able to set the stage for because a prosecution was not viable and never would be," Castor said during a hearing in a suburban Philadelphia court. "I was hopeful that I had made Ms Constand a millionaire."
Castor said his decision not to prosecute Cosby prevented the entertainer from invoking his constitutional right against self-incrimination when he gave a deposition for a civil suit against Constand.
A judge last year unsealed that testimony, in which Cosby acknowledged giving what he described as Benadryl to Constand in 2004 but portrayed the encounter as consensual.
Constand, now 44, said Cosby plied her with drugs and alcohol before sexually assaulting her.
A California judge on Tuesday ordered Cosby to give a new deposition in a separate civil lawsuit brought by a woman who accused him of sexually assaulting her at the Playboy Mansion in 1974, when she was 15 years old.