A federal judge in New York has denied Bill O'Reilly's motion to seal settlement agreements he struck with multiple women who accused him of harassment, dealing a huge blow to the former Fox News host in a defamation suit brought last year.

Deborah Batts, the judge presiding over the defamation suit, ruled Tuesday that O'Reilly "has failed to present compelling countervailing factors that could overcome the presumption of public access" to the agreements.

Batts also said O'Reilly "has not even come close to rebutting this First Amendment presumption" that favors public access to documents.

"Defendant O'Reilly asks the Court to resolve a dispute by relying on the very Agreements he seeks to shield from public view," Batts wrote.

The judge's ruling means that certain terms of the settlements are coming to light for the first time. On Wednesday, Neil Mullin and Nancy Erika Smith, the attorneys representing the three plaintiffs, introduced to the court settlement agreements between O'Reilly and women who had sued and settled with him. The agreement struck with Andrea Mackris, a former Fox News producer who filed a sexual harassment lawsuit against O'Reilly in 2004, required all parties in the case to disclaim any of the evidence "as counterfeit or forgeries" should it be made public.

As Smith and Mullin put it in a separate filing on Wednesday, the provision required Mackris to "lie -- even in legal proceedings or under oath -- if any evidence becomes public, by calling evidence 'counterfeit' or 'forgeries.'"

The potential penalties etched in the settlements were particularly onerous. If Mackris goes public about the details of the settlement, the agreement stated that she "shall return all sums paid under this Agreement, forfeit any future payments due under this Agreement, disgorge to O'Reilly the value of any benefit earned or received as a result of such disclosure, and pay to O'Reilly all reasonable attorney's fees and costs incurred by O'Reilly in attempting to enforce this Agreement."

The filing from Smith and Mullin asserts that Mackris' attorney at the time, Benedict Morelli, switched sides and agreed to become O'Reilly's lawyer while negotiating the agreement.

"This profoundly unethical conflict left Ms. Mackris virtually without legal counsel," the filing said.

Morelli disputed those assertions in a statement.

"We worked extremely hard to secure a significant financial settlement for her (Mackris)," he said. "The claim that I did not vigorously represent her, or that I represented O'Reilly during or after the settlement process, is absolutely false."

The Mackris settlement that was entered into the court record on Wednesday spelled it out thusly: "As an inducement to O'Reilly and Fox News to enter into this Agreement, and as a material condition thereof, the Morelli Firm (i) agrees to provide legal advice to O'Reilly regarding sexual harassment matters, and (ii) warrants and represents to O'Reilly and Fox News that it will not, and will not knowingly permit any of its employees, agents or representatives to represent, assist or cooperate with any other parties or attorneys in any action against O'Reilly, Fox News or the Companies arising out of actual or alleged sexual harassment issues, nor will they encourage any other parties or attorneys to commence any such action or proceeding."

Smith, who represented former Fox News host Gretchen Carlson in her 2016 lawsuit against the late Fox News chairman Roger Ailes, told CNN in an email that the defamation case against O'Reilly is "now moving to the bigger theme of the sheer ugliness and oppressiveness of NDA's, instead of the public's abstract view of them."

Related: Women in Bill O'Reilly defamation suit want settlement agreements made public

Mackris and Rebecca Gomez Diamond joined the defamation suit late last year that was brought by Rachel Witlieb Bernstein. All three asserted that they were smeared in various public statements by O'Reilly, Fox News and the network's parent company, 21st Century Fox. Mackris and Diamond settled with O'Reilly over sexual harassment allegations; Bernstein had accused O'Reilly of verbal abuse and discrimination.

Both the Mackris and Diamond agreements "prohibit plaintiffs from assisting or cooperating with other victims of O'Reilly's harassment," according to the filing on Wednesday.

The filing also asserts that O'Reilly "viciously defamed the plaintiffs" after a New York Times story last year revealed several settlements reached with women who had accused him of sexual misconduct or inappropriate behavior. The story prompted a large-scale advertising boycott of O'Reilly's top-rated program, which resulted in his firing from Fox weeks after the story ran.

O'Reilly has consistently denied wrongdoing, asserting that he made the settlements to protect his children from the damaging publicity. When the New York Times was preparing another story in October revealing that he had paid $32 million to a former colleague, O'Reilly lashed out at the reporters, saying he had "physical proof that this is bullshit."

The comments were published in the subsequent Times story, and cited in Wednesday's filing as an example of O'Reilly's defamatory statements.

Fred Newman, an attorney representing O'Reilly, said in a statement on Wednesday that "the only reason Bill O'Reilly settled any cases was to protect his children."

"The settlement agreements were fully negotiated by these plaintiffs who were ably advised by experienced counsel. Confidentiality and arbitration were two critical terms for which Mr. O'Reilly bargained in good faith," the statement said. "For the past 14 years, Mr. O'Reilly has always respected the agreed confidentiality of the settlement agreements, but now that the provision has been breached, Mr. O'Reilly will be taking all appropriate legal action to enforce the agreements."

The filing by the plaintiffs also says that Mackris' agreement acknowledges that Bo Dietl, a longtime private investigator and former Fox News contributor, and others "surveilled, investigated and amassed information about Ms. Mackris, including tapes, photographs, emails, letters, calendars and diaries."

In a phone interview with CNN on Wednesday, Dietl, who ran a long shot campaign for mayor of New York City last year, insisted that he has never done anything untoward in his work, and said that he was never hired by O'Reilly, Ailes or Fox. Instead, he said he was hired by the law firm that represented O'Reilly and Fox News in the case.

"There's a reason we're in a business for 33 years. We don't do anything illegal or improper," said Dietl. "All we do is find out the truth, and whatever we find we submit to the attorneys and they do what they want to do."

The court filing on Wednesday said that all plaintiffs "were forced to relinquish audio and video tapes recording O'Reilly's harassment and abuse."

Mackris claimed to have had tapes of lewd phone calls from O'Reilly, and her 2004 lawsuit included a sexually explicit transcript of one of the recordings.

In an interview with CNN last year, after O'Reilly had been ousted at Fox News, Morelli recounted Mackris' allegations.

"It was phone calls in the middle of the night, and many sexual things said by Mr. O'Reilly to my client," he said.

Morelli cast himself as a fierce defender of Macrkis in the interview; the court documents filed on Wednesday portray him in a very different light.