The court rulings are just the beginning of what could become a fierce legal clash pitting concerns about public safety and Mr. Wilson’s claim of a First Amendment right to publish the materials. His lawyer, Josh Blackman, compared it to the Pentagon Papers case, in which the Supreme Court famously rejected the government’s attempts to block news organizations from publishing a secret history of the Vietnam War.

“This is a huge free speech case,” said Mr. Blackman, who vowed to continue fighting the efforts to prevent Mr. Wilson from posting his documents online.

Critics say the homemade firearms produced by Mr. Wilson’s schematics can be printed without serial numbers or government registration. They say the firearms — known as “ghost guns” — would allow criminals and terrorists to evade detection.

Mr. Wilson challenged the Obama administration’s attempt to block publication of the blueprints in 2015, and the legal case had dragged on until last month, when the State Department concluded they do not violate the defense export controls meant to keep delicate military technology out of the hands of the country’s enemies. A court-approved settlement between the State Department and Mr. Wilson ended the legal case and gave Mr. Wilson the right to distribute the schematics.

But White House officials appeared to be caught by surprise by Monday’s flurry of legal activity. In a tweet on Tuesday morning, President Trump said he was “looking into” his administration’s decision last month to clear the way for Mr. Wilson’s actions.

Mr. Trump’s comments on Twitter underscored the competing views even inside the administration and raised the prospect of another shift in his administration’s approach.

“Already spoke to NRA, doesn’t seem to make much sense!” Mr. Trump wrote.

A spokesman for the president insisted later in the day that Mr. Trump “is committed to the safety and security of all Americans” but declined to say what — if anything — the president was prepared to do regarding Mr. Wilson’s efforts to distribute the blueprints for printed guns.