The sexual assault charges against Bill Cosby are up in the air after a former prosecutor took the stand for a day of testimony to claim he decided Cosby could "never" be charged for the 2004 assault.

Bruce Castor, former DA of Montgomery County in suburban Philadelphia, testified he made that decision so that the young woman who accused Cosby of sexual assault could compel Cosby to testify in a civil lawsuit.

But apparently, almost no one but Castor knew or understood that this agreement existed.

“To be clear, Mr. McMonagle, I’m not on your team -- I want them to win,” Castor said with an enigmatic smile to Cosby’s defense lawyer Brian McMonagle, who argued at a hearing Tuesday that the case should be thrown out based on Castor’s decision.

However, Castor may be helping Cosby’s defense team a great deal with his claims.

On Tuesday he testified that a press release he issued in 2005 announcing he would not charge Cosby was actually a coded declaration -- to press, the broader legal community, and lawyers for Cosby and Constand -- which was meant as a written declaration that Cosby could never legally be charged in this case, and could not invoke the Fifth Amendment right against self-incrimination in Constand’s lawsuit.

His intent was to "set up the dominoes to fall in such a way that Mr. Cosby would be required to testify,” he said.

The lawsuit ended with an undisclosed settlement.

"I was hopeful that I had made Ms. Constand a millionaire," Castor testified.

Montgomery County DA Kevin Steele filed criminal charges against Cosby in December after more than 50 women accused him of assault and newly unsealed documents from Constand’s lawsuit included statements by Cosby admitting to drugging and touching her.

But Castor testified that using Cosby’s testimony in the criminal case violated his constitutional rights and the terms of Castor’s agreement with Cosby’s former lawyer Wally Phillips, who is now deceased.

Prosecutors were befuddled by Castor’s defense of his claims that his 2005 press release on the case constituted a legally binding agreement, but the harshest questioning came at the end of the hearing from Judge Steven T. O’Neill.

“We have an immunity statute… Why did you not make it in writing? Why did you not do that? Do you know why didn’t you do that?” O’Neill asked Castor about the agreement that Cosby could not be prosecuted.

Castor said he did not feel any further record of his decision was needed.

“A prosecutor is the minister of justice,” he said. “I thought that meant I was supposed to seek justice.”

Castor said he decided in 2005 that the charges against Cosby could not be proven because of issues with Constand’s credibility.

She waited a year to report being drugged and digitally penetrated by Cosby in his Cheltenham Township mansion in 2004, gave inconsistent versions of events to law enforcement, and had multiple contacts with Cosby after the assault, he said.

“She had ruined her own credibility,” he said.

Despite that, Castor was convinced of Cosby’s guilt -- and wanted to aid the movement forward of Constand's lawsuit.

"I had already decided that I wanted Mr. Cosby punished in civil court," he said.

Testimony on this issue is scheduled to continue in Montgomery County Court on Wednesday.