A New York state judge ruled on Thursday that the New York Times must temporarily cease publication of articles based on internal documents from Project Veritas, which sued the newspaper for defamation last year — a decision that was sharply criticized as unconstitutional by both the leadership of the Times and press freedom advocates.

The ruling, by Westchester County Supreme Court Judge Charles D. Wood, follows a Times story last week based on memos written by the group’s media lawyer that the Times said revealed “the extent to which the group has worked with its lawyers to gauge how far its deceptive reporting practices can go before running afoul of federal laws.”

On Monday, a lawyer representing Project Veritas suggested that the federal authorities leaked legal memos to the Times after obtaining them during a raid this month on the home of the group’s founder, James O’Keefe, as part of an investigation into the circumstances surrounding diary pages purportedly belonging to President Biden’s daughter that were published shortly before the 2020 election.

Project Veritas — an organization that has used deceptive tactics in some of its attempts to capture proof of what it says is liberal bias and corruption in mainstream media and government — acknowledged that it once had possession of the diary, but it said it gave the diary to law enforcement and denied having anything to do with its publication by another right-wing site.

Danielle Rhoades Ha, a spokeswoman for the Times, said the legal memos were received “prior to the FBI executing its search warrants.” Joel Kurtzberg, a lawyer representing the newspaper, in addition denied that the memos were “obtained improperly.”

On Wednesday, Project Veritas filed a motion asking the court to block the Times from publishing more material from its internal documents, with a complicated argument linking the reporting of last week’s story to the newspaper’s legal maneuvers in the ongoing defamation lawsuit.

Project Veritas claimed that by “surreptitiously” obtaining the memos, the Times had “circumvented” the lawsuit’s official discovery process. In the filing, Project Veritas called the decision to publish the memos “a bare and vindictive attempt to harm and embarrass a litigation adversary by completely disregarding the sanctity of the attorney-client relationship.”

In his ruling Thursday, Wood ordered the Times to argue why it is justified in publishing the story at a hearing on Tuesday, but in the meantime to “immediately sequester, protect, and refrain from further disseminating or publishing any of Plaintiff Project Veritas’ privileged materials.”

Dean Baquet, the Times’s executive editor, criticized the ruling as “prior restraint” and a violation of bedrock First Amendment principles that have been enshrined by the U.S. Supreme Court.

“This ruling is unconstitutional and sets a dangerous precedent,” Baquet said in a statement. “When a court silences journalism, it fails its citizens and undermines their right to know. The Supreme Court made that clear in the Pentagon Papers case, a landmark ruling against prior restraint blocking the publication of newsworthy journalism. That principle clearly applies here. We are seeking an immediate review of this decision.”

Bruce Brown, executive director of the Reporters Committee for Freedom of the Press, described the ruling as “the first prior restraint entered against the New York Times since the Pentagon Papers.” Any such orders not to publish a story “are among the most serious threats to press freedom,” he added. “The trial court should have never entered this order. If it doesn’t immediately vacate the prior restraint, an appellate court must step in and do so.”

The Freedom of the Press Foundation called the ruling “shocking and troubling.”

But Elizabeth M. Locke, a lawyer representing Project Veritas, said in a statement that the ruling does not constitute prior restraint because the article in question was already published.

“Here, the Times already published Veritas’ attorney-client privileged communications,” she said, “and the interim order and more permanent relief sought are narrowly tailored to that misconduct.”

Locke added that courts have the authority to forbid publication of materials in advance in some circumstances, such as through protective orders in civil litigation.

“This is no greater restraint than the myriad protective orders the Times has been subject to in other litigation proceedings,” she said.

Elahe Izadi contributed to this report.

This story was updated Friday afternoon.