A federal judge on Thursday rejected John Bolton’s bid to dismiss a government lawsuit seeking the proceeds of his memoir, ruling that the former Trump national security adviser was required to let the White House complete a prepublication review.

U.S. District Judge Royce C. Lamberth of Washington, D.C., said the government had sufficiently alleged that Bolton violated a nondisclosure agreement by not waiting for written White House authorization before giving his publisher a manuscript for “The Room Where It Happened,” an explosive account of his 17 months at Trump’s top security adviser that was published in June.

“The government has the power to prevent harm to the national security,” Lamberth wrote in a 26-page opinion. “While the government may not prevent Bolton from publishing unclassified materials, it may require him to undergo a reasonable prepublication review process. The . . . agreements are thus consistent with the First Amendment.”

In a statement, lead Bolton attorney Charles J. Cooper said, “The Court’s decision, which we are still studying, means that the case will now move forward to the phase in which the parties will develop and present their evidence to the Court.”

Legal analysts said Lamberth’s opinion underscored that Bolton is in serious legal jeopardy and made it more difficult for other national security professionals to publish without risk of being sued by the government.

“This is a horrible new precedent,” Mark S. Zaid, a lawyer who specializes in national security and whistleblower cases, said in an email. “Before this case the U.S. Government had never pursued anyone for simply sharing a draft manuscript with lawyers, literary agents or publishers, even though by law it was improper to do so. As long as the manuscript was approved before actual publication, the U.S. Government was satisfied. But now the rules have changed, and any dissemination can create liability. “

Bolton has alleged that Trump appointees took unprecedented steps to hijack the prepublication review by erroneously claiming the book contained classified information after the National Security Council’s career senior director for information security told Bolton she had finished her own months-long review and declared it did not.

Bolton asserted that the White House sought to block the book to protect Trump from political embarrassment before November’s election.

Bolton’s book presented Trump as “stunningly uninformed” president who repeatedly sought foreign leaders’ assistance for his personal benefit. Bolton’s book said Trump asked Chinese President Xi Jinping to help him win reelection and dangled military aid to pressure Ukraine to investigate former vice president Joe Biden’s son.

Justice Department attorneys acknowledged they were unaware of past instances in which political appointees have conducted a second prepublication review. However, they argued, and Lamberth appeared to agree, that if Bolton was dissatisfied, his recourse was to sue the Trump administration on First Amendment grounds, rather than unilaterally publish without approval.

The government sued to prevent the sale of already distributed books, but Lamberth refused to halt publication in a June 20 ruling, saying the government acted too late.

Still pending before the judge are a government motion for a summary ruling to place Bolton’s proceeds in a constructive trust because the book contained classified information, and Bolton’s motion that he first be permitted to investigate whether the government improperly politicized that determination.

Lamberth’s opinion gave a close reading to the terms of agreement Bolton signed. The opinion rejected Bolton’s assertion that the government had to prove he knowingly disclosed materials that “are, relate to, or purport to be” Top Secret/Sensitive Compartmented Information — the highest level of classification, concerning intelligence sources and methods — “or describe activities that produce or relate to SCI.”

Instead, the court found that the requirement to submit his work for review was triggered simply by his decision to draft a work for publication describing his tenure as the president’s top security aide.

“Bolton wrote a memoir of his time serving as National Security Advisor — a role pervaded with SCI,” Lamberth ruled. “Writing a book about the work of the National Security Advisor alone triggers prepublication review, because any detailed description of the National Security Advisor’s work relates to SCI.”

Lamberth said any First Amendment implications were limited because the agreements Bolton signed “require swift action,” namely that the government must make an initial response within 30 working days.