The lawyer for British socialite Ghislaine Maxwell, an alleged madam for deceased financier Jeffrey Epstein, said the case against her should be thrown out and she should be freed on the same grounds used to free Bill Cosby, which stems from a sweetheart deal given to Epstein more than a decade ago. 

Cosby was released from prison Wednesday when his sexual assault conviction was overturned after the Pennsylvania Supreme Court ruled the prosecutor who brought the case was bound by his predecessor's agreement not to charge him. 

"She should not have to fight her case at trial and her case should be thrown out, just like Cosby's has been, because prosecutors promised Epstein when he pleaded guilty that they would not prosecute her," Maxwell's appellate lawyer, David Oscar Markus, wrote in a New York Daily News op-ed published Wednesday.

BILL COSBY ENJOYED PIZZA, WAS CRACKING JOKES ON FIRST NIGHT AT HOME AFTER PRISON RELEASE

Bill Cosby reacts outside his home in Elkins Park, Pa., Wednesday after being released from prison. Pennsylvania's highest court has overturned comedian Bill Cosby's sex assault conviction. (AP Photo/Matt Slocum)

Bill Cosby reacts outside his home in Elkins Park, Pa., Wednesday after being released from prison. Pennsylvania's highest court has overturned comedian Bill Cosby's sex assault conviction. (AP Photo/Matt Slocum) (AP Photo/Matt Slocum//Twitter)

Markus was referring to a 2007 plea deal Epstein made with federal prosecutors in which they promised not to charge his co-conspirators. Prosecutors have said the deal doesn't apply to Maxwell, 59, since it was negotiated in Florida. 

She is federally charged in New York. Cosby was convicted on state charges. 

"But the principle of law is the same and holds true in both state and federal courts," Markus told Fox News. "When the government makes a promise, whether state or federal, it has to live up to that promise and can’t simply abandon it."

Ghislaine Maxwell

Ghislaine Maxwell

Maxwell is scheduled to go to trial in September. She was not named as a co-conspirator at the time Epstein made his plea deal. 

"She has now been charged as a co-conspirator and the agreement says that they can’t prosecute co-conspirators," Markus said. "Seems pretty clear!"

Maxwell was arrested last summer and faces charges of recruiting, grooming and trafficking girls to be sexually abused by Epstein in the 1990s through 2004 and for lying under oath. She has pleaded not guilty and has been repeatedly denied bail because she is deemed a flight risk, with judges citing her British and French passports and her wealth. 

Jeffrey Epstein   Images Ghislaine Maxwell. Maxwell is charged with recruiting young girls for Epstein to be sexually abused.

Jeffrey Epstein   Images Ghislaine Maxwell. Maxwell is charged with recruiting young girls for Epstein to be sexually abused. (Getty Images)

Cosby was promised in 2005 by Bruce Castor, who was the Montgomery district attorney at the time, that he would not be prosecuted because of insufficient evidence. The court ruled in a 79-page opinion that District Attorney Kevin Steele, the prosecutor who brought the case against Cosby, violated an agreement made with Castor, though the deal had apparently never been put in writing. 

CLICK HERE TO GET THE FOX NEWS APP

"The Cosby case reaffirms that a prosecutor is bound to act with integrity and the public must be able to rely on his word," Markus wrote. "What a concept."