A spokesman for 21st Century Fox, the parent company of Fox News, declined to comment.

In the defamation suit, the women asserted that comments by Mr. O’Reilly; Rupert Murdoch, the executive chairman of 21st Century Fox; and the company falsely depicted them as liars, political operatives and extortionists after an investigation by The Times that exposed how the network stood by Mr. O’Reilly as he faced a series of harassment allegations.

Lawyers for Mr. O’Reilly and Fox News have argued for the dismissal of the lawsuit, stating they had not disparaged the women and that the claims by Ms. Mackris and Ms. Diamond should be moved to confidential arbitration proceedings because of stipulations in their settlement agreements.

Last month, Mr. O’Reilly’s lawyers requested that he be able to file “certain agreements that contain strict confidentiality provisions” under seal, but Judge Deborah A. Batts, of the United States District Court, rejected that request, stating that there is a presumption of public access to court documents and that Mr. O’Reilly had failed to meet the burden of demonstrating privacy concerns.

Lawyers for the women filed the settlement documents on Wednesday as part of a court filing.

The agreement with Ms. Mackris, the former producer on Mr. O’Reilly’s program on Fox News who sued him in 2004, accusing him of sexual harassment, includes a previously unknown provision showing that her lawyers agreed to change sides to work for Mr. O’Reilly after the salacious dispute. It was settled for about $9 million, according to people familiar with the matter. The mediator for the dispute was the lawyer Marc E. Kasowitz, who went on to represent Mr. O’Reilly last year. (Mr. Kasowitz also has represented President Trump.)

As part of the settlement, Ms. Mackris’s former lawyers at the firm Benedict P. Morelli & Associates agreed to provide legal advice to Mr. O’Reilly on sexual harassment matters. They also agreed not to represent other parties with sexual harassment claims against Mr. O’Reilly or Fox News.

Such arrangements are considered unethical in the legal community because they can create conflicts of interest between lawyers and their clients and sideline lawyers who have the expertise to bring claims against companies and individuals.

In a statement, Mr. Morelli said: “Every step we took was to negotiate the best possible deal for Ms. Mackris. We worked extremely hard to secure a significant financial settlement for her. 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 agreement between Mr. O’Reilly and Ms. Mackris nods to the potential for ethical concerns, requiring both of them to waive the conflicts of interest in Mr. O’Reilly’s retention of the Morelli firm. It states that, if the provision is found to violate the American Bar Association or New York professional codes, the rest of the agreement would remain “valid and binding.”