As Bill Cosby awaits a second sex-assault trial in Montgomery County, the former district attorney who declined to press charges against the entertainer in 2005 is suing the alleged victim in the case.

Bruce L. Castor Jr. filed a personal injury claim against Andrea Constand and her lawyers this month in Philadelphia Common Pleas Court, seeking more than $50,000 in damages and adding yet another legal battle to the several lawsuits already surrounding the allegations that Cosby drugged and molested Constand in 2004.

James Beasley Jr., Castor's lawyer in that case, said Friday that he soon would file a complaint claiming that Constand sued Castor for defamation in 2015 to influence that year's election for district attorney. Castor, a Republican, lost that race to Democrat Kevin R. Steele, who ran TV ads criticizing Castor's handling of the 2005 investigation into Cosby. That investigation was reopened in the months before the election.

Constand "was trying to gain a tactical advantage with the election in order to get Kevin Steele put in so that she could get Cosby prosecuted," Beasley said.

Jeffrey McCarron, a lawyer representing Constand's lawyers, said Beasley's description of the lawsuit sounded "legally deficient."

"If his described basis is the reason for the lawsuit, then we do not expect it will last very long," McCarron said.

Although Castor last handled the case more than 12 years ago, he has been inextricably linked to the current prosecution. He spoke publicly about his 2005 decision as dozens of Cosby accusers came forward in 2014, saying that he believed Constand's allegations. He is defending himself against Constand's defamation lawsuit. He testified as a key defense witness in a bid to have the charges thrown out. And after the case ended in mistrial, he issued a statement that he thought Constand was "probably the victim of a sexual assault," but that "`probably' does not win criminal trials."

Cosby's first trial on charges of aggravated indecent assault ended with a hung jury in June. The 80-year-old entertainer is scheduled for a retrial in April in Norristown. He also previously faced a 2005 civil lawsuit filed by Constand that was settled out of court.

The incident involving Constand is the only case for which Cosby faces criminal charges. He has been accused of sexual misconduct by dozens of women. Cosby has denied having any non-consensual sexual interactions.

Constand's lawyers, meanwhile, have accused Castor of working to help Cosby's defense lawyers. In the defamation lawsuit against Castor, still pending in U.S. District Court in Philadelphia, they argued that anything containing personal information about Constand should be kept under seal so it cannot be used against her at Cosby's trial.

Court records show that Castor forwarded emails to Cosby's lawyer that he sent in the fall of 2015 to then-District Attorney Risa Vetri Ferman, who had reopened the Cosby investigation. And in January 2016, days after Cosby was charged, Castor wrote an email about the case to Brian McMonagle, Cosby's defense lawyer, saying that Steele "threw the Cosby 'Hail Mary' pass" to win the election.

"I am appalled at what is happening," Castor wrote in the email, which was included in court filings by Constand's lawyers.

Castor was a witness for Cosby's defense team at a 2016 hearing in which Cosby's lawyers unsuccessfully argued that the case should be dropped because Castor made a binding nonprosecution agreement in 2005.

Constand's lawyers also cited a deposition from Brian Miles, a political adviser to Castor in his 2015 run for district attorney. Miles said that he and Castor discussed the possibility that Cosby could face charges, but that Castor did not bring up a nonprosecution agreement, according to excerpts of his deposition provided in court filings.

Dolores Troiani, Constand's lawyer, said in a court filing that those examples showed that Castor had tried to undermine the criminal case against Cosby, a claim his lawyers have denied.

"We believe that what is going on here is an attempt to get this information in the hands of Cosby," Troiani told U.S. District Judge Eduardo Robreno at a hearing Friday morning.

Troiani argued that filings in the case should be kept under seal so she could ensure that no sensitive or personal information about Constand is made public and used against her in Cosby's second trial.

Castor's lawyers argued that Constand gave up some right to privacy by suing Castor.

"There's absolutely no basis" for filings to be made under seal, said Mary Beth Hughes, a lawyer representing Castor.

Robreno ruled Friday that Castor's lawyer must file motions under a temporary seal and must give Constand's lawyers an opportunity to argue that certain portions must be kept under seal or redacted.