"The undisputed record shows that the challenged actions constituted unlawful retaliation in violation of the First Amendment, and that Anthropic was denied the pre-deprivation process required under the Fifth Amendment," US District Judge Rita F. Lin wrote in a ruling on Thursday.
"The record further shows no material dispute that Secretary Hegseth's decision to designate Anthropic a supply chain risk violated the governing statutory scheme... and was arbitrary and capricious."
The dispute between the AI company and the government broke out in February when US President Donald Trump and Defence Secretary Pete Hegseth accused Anthropic of endangering national security and designated the company a supply chain risk.
Anthropic CEO Dario Amodei refused to back down over concerns the company's products could be used for mass surveillance or autonomous armed drones.
Lin wrote the US government's actions "were based on a desire to make a public example out of Anthropic for its 'arrogance' in criticising the government, not based on any articulable basis to believe that Anthropic would actually sabotage its model."
An Anthropic spokesperson said in a statement the company welcomed the judge's ruling: "We remain focused on working productively with the government to harness AI for our national security so all Americans benefit from this technology."
The White House did not immediately respond to a request for comment.
In the 59-page ruling, Lin wrote neither the US Constitution nor the federal statute the government invoked allows them to "impose sweeping penalties based principally on Anthropic's critique of the administration's views."
Anthropic sued the Pentagon over the supply chain risk designation in March for what it called an "unlawful campaign of retaliation" over its refusal to allow unrestricted military use of its technology.
The legal challenge intensified an unusually public dispute over how AI can be used in warfare and mass surveillance. Anthropic's primary tech industry rival, ChatGPT maker OpenAI, made its own deal to work with the Pentagon just hours after the government punished Anthropic for its stance.
Anthropic and OpenAI are each ramping up for buzzy initial public offerings.
Anthropic has also filed a separate and narrower case that is still pending in the federal appeals court in Washington. That case involves a different rule the Pentagon is using to try to declare Anthropic a supply chain risk.
with AP