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.”