The New York Times said on Tuesday night that it had severed its ties with David Boies, one of the country’s most prominent litigators, after he was linked to a clandestine effort to spy on the newspaper’s reporters and prevent the publication of a damaging story about disgraced Hollywood producer Harvey Weinstein.

“We never contemplated that the law firm would contract with an intelligence firm to conduct a secret spying operation aimed at our reporting and our reporters,” the newspaper said in a statement on Tuesday night.

On Monday night, The New Yorker had detailed the extensive efforts Weinstein used to keep his sexual misconduct out of the public spotlight over the past year. His arsenal of tricks included the use of private investigators to ferret out details about imminent reporting into his wrongdoing. Some of those investigators met with journalists and victims while posing as women’s-rights advocates or victims themselves to determine what they knew.

At the nexus of Weinstein’s efforts was Boies and his high-profile firm Boies Schiller & Flexner. Boies personally signed a contract in July with Black Cube, a private-intelligence agency that touts ex-Mossad agents in its workforce, to uncover information that would discredit a New York Times story about Weinstein’s victims and a then-forthcoming book by actress Rose McGowan. (Weinstein has admitted to sexual misconduct but denied that it was nonconsensual.)

Boies’s involvement in the saga is a public-relations nightmare for himself and his firm, as my colleague Gillian White explained. But legal experts also raised concerns about the ethical questions that may arise from Boies Schiller’s simultaneous representation of the Times in a libel lawsuit, which could be seen as a conflict of interest, as well as Black Cube’s clandestine activities on Weinstein’s behalf.

“Lawyers are not permitted to engage in dishonesty or deceit,” Kathleen Clark, a Washington University law professor who specializes in legal ethics, told me. “Black Cube seems to make its living by engaging in dishonesty and deceit, at least in part.”

Boies, for his part, cast his role in the saga as that of a bystander. He says he counseled Weinstein “that the story could not be stopped by threats or influence and that the only way the story could be stopped was by convincing the Times that there was no rape,” according to The New Yorker. “If evidence could be uncovered to convince the Times the charges should not be published, I did not believe, and do not believe, that that would be averse to the Times’ interest.”

In an email to Boies Schiller staff on Tuesday afternoon that the firm shared with The Atlantic, Boies offered a longer account of events that further distanced himself from Weinstein’s efforts. “I told Mr. Weinstein at that time that neither I nor the Firm would represent him in this matter, and he hired several other lawyers to represent him,” he wrote. Those lawyers then sought out Black Cube and other investigators and wrote up a contract for their services. Boies, by his own telling, then returned to sign a contract drafted by other lawyers between a client he wasn’t representing and private investigators he didn’t choose or oversee in a matter he says he had declined to take part.

Boies described this participation as “a reasonable accommodation to a longtime client” that he now regrets. “It was a mistake to contract with, and pay on behalf of a client, investigators who we did not select and did not control,” he said in the email. “It was not thought through, and that was my mistake. I take responsibility for that.”

Boies first rose to legal stardom as a result of his antitrust crusade against Microsoft on behalf of the Justice Department during the 1990s. A political liberal who is closely associated with the Democratic Party, he represented Al Gore in the legal battles that followed the disputed 2000 presidential election. Boies later teamed up with former adversary Ted Olson, who represented George W. Bush in Bush v. Gore, in 2009 to mount a successful legal challenge to California’s constitutional amendment banning same-sex marriages.

He and his firm have a long relationship with Weinstein. In 2015, the Hollywood producer hired Boies to represent him in contract negotiations with the Weinstein Company, the influential production company Weinstein founded and had led until last month. During those negotiations, the company’s board of directors learned of confidential settlements between Weinstein and three or four accusers. Boies told the Times he had given some legal advice to Weinstein for one of those settlements but did not specify which.

The New Yorker speculated that Boies’s involvement with the Black Cube letter may have been an effort to keep secret the investigators’ activities through attorney-client privilege. But that privilege would only exist between Weinstein and Boies, not between Boies and a third party, Clark said. “There’s another privilege that’s less powerful called work-product privilege, which can apply if information is developed in anticipation of litigation,” she explained. The first paragraph of the contract between Boies Schiller and Black Cube asserts that the work was for “litigation-support services,” Clark said, “but I can’t tell whether they’re really litigation-support services or whether that’s a ruse.”

Stephen Gillers, a New York University law professor who focuses on legal ethics, said it’s not unusual for law firms to hire private investigators, especially for corporations and wealthy clients. But he noted that firms are obligated to ensure those investigators abide by the same ethical boundaries as the lawyers themselves. “Most prominently, a lawyer cannot contact an opposing client whom he knows is represented by counsel,” Gillers pointed out. “You can’t go talk to an opponent. You have to go through his lawyer.”

Boies also defended his role vis-à-vis his firm’s work on behalf of the Times in another case after Monday’s revelations drew a sharp rebuke from the the newspaper. “We learned today that the law firm of Boies Schiller & Flexner secretly worked to stop our reporting on Harvey Weinstein at the same time as the firm’s lawyers were representing us in other matters,” the Times said in a statement on Monday. “We consider this intolerable conduct, a grave betrayal of trust, and a breach of the basic professional standards that all lawyers are required to observe. It is inexcusable and we will be pursuing appropriate remedies.”

In the email to his firm, Boies said Boies Schiller’s agreement with the newspaper anticipated such a possibility. He quoted a clause notifying the Times that the firm might engage with clients outside the libel lawsuit “where the interests of the other persons, and the Firm’s representation of them, may be against the [Times’s interests], including adversity in litigation.”

The Times fired back on Tuesday night. “Such an operation is reprehensible,” the newspaper said in its statement, referring to Weinstein’s private investigators, “and the Boies firm must have known that its existence would have been material to our decision whether to continue using the firm. Whatever legalistic arguments and justifications can be made, we should have been treated better by a firm that we trusted.”

The New York State Bar Association’s rules of professional conduct instruct lawyers and law firms to “[not] engage in any conduct involving dishonesty, fraud, deceit, or misrepresentation.” Those rules also forbid lawyers from taking adverse action against a current client by negotiating against them or representing an opponent in litigation. But state disciplinary bodies, which are often underfunded, typically only enforce these rules against the worst offenders in the legal community, Gillers said.

Instead, law firms usually try to avoid conflict-of-interest situations because of the potential financial impact. “They worry about losing the client who is the target of the adverse conduct,” he explained. “They worry about losing the client they represented when they shouldn’t be representing that client. They worry about losing their fee.” The fear of lawsuits also acts as a deterrent. “Firms worry about civil liability, malpractice liability, breach-of-fiduciary-duty liability, they worry about disqualification from a matter,” Gillers said. “And they worry about adverse publicity.”