The ruling by US District Judge Karin Immergut in Portland is a setback for Trump, a Republican, as he seeks to dispatch the military to cities he describes as lawless over the objections of their Democratic leaders.
Democratic Oregon Attorney General Dan Rayfield's office filed the lawsuit on September 28, a day after Trump said he would send troops to Portland to protect federal immigration facilities from "domestic terrorists."
Oregon asked the court to declare the deployment illegal and block it from going forward, saying Trump was exaggerating the threat of protests against his immigration policies to justify illegally seizing control of state National Guard units.
While Trump described the city as "War ravaged," Oregon said that Portland protests were "small and sedate," resulting in only 25 arrests in mid-June and no arrests in the three-and-a-half-months since June 19.
Oregon's lawsuit said Trump announced the troop deployment after Fox News showed video clips from "substantially larger and more turbulent protests" in Portland in 2020.
The stark divide in how the two sides described the situation on the ground in Portland was evident at a Friday court hearing before Immergut.
US Department of Justice attorney Eric Hamilton said "vicious and cruel radicals" had laid siege to the Portland headquarters of US Immigration and Customs Enforcement.
The decision to send 200 troops - just five per cent of the number recently sent to respond to Los Angeles protests - showed restraint, Hamilton said.
Caroline Turco, representing Portland, said that there had been no violence against ICE officers for months and that recent ICE protests were "sedate" in the week before Trump declared the city to be a war zone, sometimes featuring less than a dozen protesters.
"The president's perception of what is happening in Portland is not the reality on the ground," Turco said. "The president's perception is that it is World War II out here. The reality is that this is a beautiful city with a sophisticated police force that can handle the situation."
Immergut asked lawyers how much deference she should give to Trump's description of Portland in social media posts, and seemed sceptical about treating those posts as an official legal determination.
"Really? A social media post is going to count as a presidential determination that you can send the National Guard to cities?" Immergut asked. "I mean, is that really what I should be relying on as his determination?"
Oregon's lawsuit argued that Trump's deployment violates several federal laws and the state's sovereign right to police its own citizens.
Trump's decision to send troops only to "disfavoured" Democratic cities like Portland also violates the state's rights under the 10th Amendment of the US Constitution, according to the lawsuit.
The lawsuit is the latest legal challenge to Trump's deployments of military forces to Democrat-led cities, including Los Angeles and Washington, which he says were overrun with crime and hostile to immigration enforcement.