A decade ago, Bruce L. Castor Jr. vowed that his announcement that he would not charge Bill Cosby in connection with an alleged sexual attack on a Temple University employee would be his final word on the topic.

As Cosby now awaits trial on the same accusation, the case could hinge on what the former Montgomery County district attorney says next.

Castor stands by his claim that he granted Cosby an oral "non-prosecution agreement" in 2005 - and is likely to say as much if he testifies at a pivotal hearing in two weeks.

But the lack of a record - and anyone other than Cosby to corroborate the deal - means the most important witness might be the man who once decided he could not prove that a crime had been committed, legal experts say.

"It's going to be Bruce's word against somebody else's word," said former Philadelphia District Attorney Lynne M. Abraham. "And a judge is going to have to figure out what was said, what was meant, and what the defense thought it meant."

Non-prosecution agreements are tools that prosecutors often use to get critical testimony or cooperation from an accused party.

Still, a half-dozen prosecutors, defense lawyers, and legal academics contacted by The Inquirer all say the purported agreement - as described by Cosby's lawyers in court filings and by Castor - is highly unusual. Most ask why it was not put in writing.

"It's clear in retrospect that Cosby and his attorneys didn't think that there was ever going to be any criminal prosecution," said Anne Poulin, a law professor at Villanova University. "And everyone thought they could just walk away from it. And that's fine. But that doesn't then become an enforceable agreement not to prosecute."

The effort by Cosby's lawyers to have the charges thrown out became even more tangled last weekend after the emergence of an email Castor wrote in September to his successor, Risa Vetri Ferman, at the same time he was campaigning to reclaim his old job.

In the email, reviewed by The Inquirer, Castor explained that by telling Cosby he would not prosecute him, he hoped to create an environment in which the entertainer's accuser, Andrea Constand, might prevail in a civil case she filed against him.

Castor investigated Constand's claim that Cosby drugged and assaulted her in January 2004 at his Cheltenham mansion, but concluded he lacked evidence to win a conviction.

After conferring with lawyers for Cosby and Constand, Castor said, he agreed to waive all future prosecution on the allegations, hoping to erase any reason for Cosby to refuse to testify in the civil case.

"I intentionally and specifically bound the commonwealth that there would be no state prosecution of Cosby in order to remove from him the ability to claim his Fifth Amendment protection against self-incrimination, thus forcing him to sit for a deposition under oath," Castor wrote in the email.

The lawyer who negotiated the purported agreement for Cosby - his then-defense attorney, Walter M. Phillips Jr. - died last year.

Castor did not respond to requests for comment, nor did the civil-case lawyer, Patrick O'Connor, who worked closely with Phillips in 2005. Castor has said O'Connor was not part of the negotiations for the non-prosecution agreement.

Cosby did sit for a deposition in the civil case, and later paid an undisclosed sum to settle it out of court. Portions of that deposition surfaced only in the last year, and were referenced in his charging documents last month.

In his email to Ferman, Castor warned her against pursuing the case or using that deposition, predicting that she or the office could be held liable for violating his deal.

Constand's lawyers say that Castor is lying and that they never would have agreed to any arrangement that could bar Cosby from being prosecuted. "From our perspective, there was no agreement," Bebe Kivitz, one of Constand's lawyers, said in 2005. "I never spoke to Bruce L. Castor Jr. Nor would I have agreed."

What's more, Kivitz said, her primary contact with Castor's office during the investigation a decade ago was his first assistant, Ferman, the same prosecutor who reopened the investigation in her final months in office last year.

Kevin Steele, who took over as district attorney this month, has been accused by Cosby's attorneys of bringing the charges to boost his campaign against Castor last fall. Steele has not filed a response to the defense team's allegation, but has said that there was no evidence of a non-prosecution deal and that the defense claims have no merit.

Whether or not an enforceable deal existed, legal experts asked why Cosby's attorneys never obtained any promise in writing before sending their client into a potentially damaging deposition in the civil case.

Formal immunity agreements, which often are granted to a witness in return for testimony or cooperation, must be approved by a judge. But experts said non-prosecution agreements, which are less formal, still typically lay out specific terms and are signed by all parties.

"If I'm Cosby's attorneys, there's no way that I would not have that in writing signed by the prosecutor," said John Clune, a Denver lawyer who represented an accuser of Kobe Bryant in a 2004 sexual assault lawsuit ultimately settled out of court.

Even with an agreement such as the one Castor described, defense lawyer Mark Geragos said, he still would never let his client testify without something formally approved by a judge.

"If that were my client and I'm in that deposition, I would have tackled him and slugged him in the head," said Geragos, whose celebrity clients have included Michael Jackson. "There's no way you let the guy answer those questions when you know there's a statute of limitations that's that long [12 years] in the jurisdiction and you don't have immunity."

The deposition transcript shows Cosby conceded several points of Constand's story, including that they had a sexual encounter on the night in 2004 she claims she was attacked and that he gave her three blue pills when she complained of not feeling well. He maintains that the pills were antihistamines and that Constand consented to their sexual contact.

Legal experts characterized the role Castor describes for himself in the email - negotiating an oral non-prosecution agreement in order to help one side in a civil case - as unusual for a prosecutor.

"Your elected position is to prosecute," said Abraham, the former Philadelphia district attorney. "Whether there were any civil consequences was something I never concerned myself with. My role [as a prosecutor] isn't to negotiate deals between civil lawyers."

Even if Cosby's lawyers can convince a judge that an agreement was in place in 2005, it is unlikely such a deal would sink the current case, said Karen Steinhauser, a University of Denver law professor and a former sex-crimes prosecutor.

The criminal affidavit Steele filed against Cosby in December cites several new interviews with Constand and other witnesses, and draws on detailed descriptions of the sexual encounter from Cosby's 2005 statement to police.

"You can't bind the hands of prosecutors who get independent evidence of a crime," Steinhauser said.

Common Pleas Court Judge Steven O'Neill is scheduled to consider the arguments at a Feb. 2 hearing in Norristown. Whatever he decides, the issue of whether prosecutors can use the deposition against Cosby is unlikely to go away, Geragos said.

"Clearly it's a legitimate issue," he said.

Cosby, 78, has denied assaulting Constand or any of the dozens of women who have made similar allegations in the years since she came forward. He remains free pending his trial on $1 million bail. If convicted of aggravated indecent assault, he faces up to 10 years in prison.