WASHINGTON — For years, Cody Wilson, a champion of gun-rights and anarchism from Texas, has waged a battle to post on the internet the blueprints for making plastic guns on 3D printers, claiming the First Amendment gives him the right to do it.

Plastic guns are difficult to detect, and concerned about making it easier to produce them, the Obama administration had used export laws banning the foreign distribution of firearms to prevent the publication of the blueprint. But an abrupt reversal by the State Department last month appeared to finally clear the path for Wilson to usher in what his website calls “the age of the downloadable gun.”

That age, he said, would start Wednesday when he would begin uploading the instructions. But faced with dire warnings about an imminent risk to public safety from alarmed public officials across the country, a federal judge in Seattle on Tuesday evening abruptly granted a temporary nationwide injunction blocking Wilson from moving forward with his plans.

Attorneys general in eight states and the District of Columbia had filed a joint lawsuit attempting to force the Trump administration to prevent Wilson’s nonprofit organization, Defense Distributed, from making the technical plans for the plastic guns available online.

In a decision from the bench issued immediately after an hourlong argument by lawyers for both sides, Judge Robert S. Lasnik of U.S. District Court said the lawyers bringing the suit had established “a likelihood of irreparable harm” and of success on the merits.

Lasnik said in his ruling there were “serious First Amendment issues” that would need to be worked out later in court, but that for the moment, there should be “no posting of instructions of how to produce 3-D guns on the internet.” The judge set a follow-up hearing for Aug. 10 in his courtroom in downtown Seattle.

The decision followed a legal skirmish in New Jersey on Tuesday afternoon in which Wilson agreed to stop uploading new files to his website and to prevent internet users in the state from downloading the plans until a full hearing in September. State officials in Pennsylvania won a similar temporary concession on Sunday.

“Cody Wilson backs down,” New Jersey Attorney General Gurbir Grewal said on Twitter. “The fight for public safety continues.”

The court rulings are just the beginning of what could become a fierce legal clash pitting concerns about public safety and 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 Blackman, who vowed to continue fighting the efforts to prevent Wilson from posting his documents online.

Critics say the homemade firearms produced by 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.

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 Wilson ended the legal case and gave 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 Donald Trump said he was “looking into” his administration’s decision last month to clear the way for Wilson’s actions.

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!” Trump wrote.

A spokesman for the president insisted later in the day that 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 Wilson’s efforts to distribute the blueprints for printed guns.

Hogan Gidley, a deputy White House press secretary, noted that federal law already makes it illegal to own or make a gun out of only plastic. But Gidley did not address the issue of Wilson’s desire to distribute the instructions for how to do so.

“The administration supports this nearly two-decade-old law,” Gidley said. “We will continue to look at all options available to us to do what is necessary to protect Americans while also supporting the First and Second amendments.”

Wilson expressed disappointment Tuesday evening after the ruling by the judge in Washington state.

“The law is clear,” Wilson said. “These plaintiffs just don’t have standing to challenge the settlement. You can’t unclose a federally closed matter. And I consider the matter to be closed.”

The attorneys general had urged a judge to block Wilson’s plans on the grounds that allowing the company to continue posting the blueprints online is a threat to public safety and that terrorists could use hard-to-trace plastic weapons to evade detection by metal detectors.

“3-D printed guns are functional weapons that are often unrecognizable by standard metal detectors because they are made out of materials other than metal (e.g., plastic) and untraceable because they contain no serial numbers,” state officials said in the lawsuit. “Anyone with access to the CAD files and a commercially available 3-D printer could readily manufacture, possess or sell such a weapon.”

On Capitol Hill on Tuesday morning, alarmed Senate Democrats declared that Trump would be responsible for any injuries or deaths resulting from untraceable 3D plastic guns, and called on him to reverse the policy immediately.

“It’s his doing, it’s his responsibility and the blood is going to be on his hands,” said Sen. Richard Blumenthal, D-Conn. “He can tweet from now until the end of his administration, but the hard reality is that he can stop needless death and injury in America.” Sen. Edward J. Markey, D-Mass., said, “Donald Trump will be totally responsible for every downloadable plastic AR-15 that will be roaming the streets of our country.”

Blumenthal and Markey were among a group of Democrats who announced they were introducing two separate bills related to 3D guns: one that would bar the manufacture and sale of any untraceable weapon, and another that would prohibit the online publication of blueprints for the plastic guns.

But passing gun legislation in Congress has proved nearly impossible, and the House has already left for its August recess, which means no bill can be taken up until September. While the lawmakers said they are soliciting Republican support, at least one Republican, Sen. Mike Rounds of South Dakota, said it would be extremely difficult to stop the proliferation of the weapons.

“This is a new technology which you’re not going to put back into the bottle, it is there,” Rounds said, adding that the smarter course would be to “create new technologies and utilize new technologies” — such as metal detectors that could also recognize plastic — in schools, airports and other public places.

Dana Loesch, a spokeswoman for the National Rifle Association, mocked Democrats last week for concerns about the 3D guns, and said that attempts to regulate the technology would be “absolutely unenforceable.” The guns were “what the rest of us call freedom and innovation,” she said in a video segment posted on NRATV, the organization’s online video channel.

Lawrence Keane, who handles government affairs for the National Shooting Sports Foundation, said that the gun group does not “see this as a significant issue from a law enforcement, public safety perspective.”

He predicted that few people would spend the money and time for an expensive 3D printer that would produce an unreliable firearm. But while he played down any effect downloadable guns could have on crime, he also discouraged gun enthusiasts from trying to print firearms themselves.

“As an industry, we certainly don’t advocate that hobbyists try to do this in their basement, any more than General Motors would encourage someone to go out and build a car at home,” he said.

Defense Distributed officials have argued that they have a First Amendment right to post the blueprints for the guns online, and have characterized the government’s long-running attempts to block it as an ideological, anti-gun campaign.

Wilson is a well-known figure on the far right, seen as a champion for both firearms enthusiasts and anarchists. But his efforts to distribute instructions to create 3D printed guns on his website could lead to divisions between the groups, said Timothy D. Lytton, a law professor at Georgia State University who has studied guns.

“This could be one of the first issues ever to come along that represents a wedge between two constituents that are very vocal in their support for Trump,” he said. “Gun enthusiasts are generally in favor of some sort of background check system, for law and order — they don’t want a free-for-all where everyone can get guns, unlike anarchists.”

Homemade firearms are not illegal, but all-plastic versions are. The Undetectable Firearms Act prohibits owning a gun that can pass through a metal detector unnoticed. Firearms commerce is more regulated. Dealers must be licensed and customers must pass a federal background check, although private sellers are sometimes able to bypass the requirement.

Because of congressional protection granted in 2005, gun manufacturers and sellers are largely shielded from liability when their weapons are used in crimes. But Wilson might be vulnerable to negligence lawsuits because he has presented himself as a purveyor of digital data, rather than as a producer or dealer of firearms, Lytton said.

Homemade guns predate computer code by decades. Consumers have long been able to purchase kits with unfinished, untraceable gun parts and assemble the firearms themselves.

The advent of 3D printers, the cheapest of which can be bought for a few hundred dollars, made possible the creation of functioning weapons with one of the printers, though currently only more expensive ones are likely to be able to reliably make the firearms.

“This is a high-tech version of what’s been going on in the margins of the gun industry for a long time — looking for clever ways to market firearms that evade federal restrictions,” Lytton said.