A federal judge in Oregon on Friday issued a permanent injunction barring the Trump administration from deploying the National Guard on the streets of Portland in response to protests against the president’s immigration policies.

“This Court arrives at the necessary conclusion that there was neither ‘a rebellion or danger of a rebellion’ nor was the President ‘unable with the regular forces to execute the laws of the United States’ in Oregon when he ordered the federalization and deployment of the National Guard,” U.S. District Judge Karin J. Immergut, who was appointed by President Donald Trump in his first term, wrote in her ruling.

The Trump administration can appeal the ruling if it wants to.

Oregon Gov. Tina Kotek responded to the ruling Friday, calling Trump’s move to federalize the guard “a gross abuse of power.”

“Oregon National Guard members have been away from their jobs and families for 38 days. The California National Guard has been here for just over one month. Based on this ruling, I am renewing my call to the Trump Administration to send all troops home now,” Kotek said.

California Attorney General Rob Bonta, whose justice department argued in the case objecting over his state’s National Guard’s deployment, called the decision “a win for the rule of law, for the constitutional values that govern our democracy, and for the American people.”

The White House did not immediately respond to a request for comment on the ruling.

Immergut had previously issued a temporary restraining order barring the Guard from being deployed in Oregon, which the Trump administration was appealing.

Oregon officials have been embroiled in a complicated legal battle with the administration since late September, when, at Trump’s direction, Defense Secretary Pete Hegseth mobilized around 200 troops to the city amid ongoing protests outside an immigration processing facility.

The city and the state sued on Sept. 28 to block the use of military troops in Portland, arguing it was unnecessary and unlawful.

Immergut signed off on a temporary restraining order blocking the administration from deploying the state National Guard on Oct. 4, and a day later issued a second order blocking deployment of National Guard troops from other states to Portland streets.

She said in her order that it appeared Trump was acting in bad faith with highly exaggerated claims of violence in the city, including saying it was “war ravaged” with “ICE Facilities under siege from attack by Antifa” and “crazy people” who “try to burn down buildings, including federal buildings” every night.

“The President’s determination was simply untethered to the facts,” Immergut wrote.

The Justice Department immediately appealed, arguing her decision “improperly impinges on the Commander in Chief’s supervision of military operations, countermands a military directive to officers in the field, and endangers federal personnel and property.”

Its attorneys argued Trump’s “determination was amply justified by the facts on the ground.”

“In the weeks and months preceding the President’s decision, agitators assaulted federal officers and damaged federal property in numerous ways, spray-painted violent threats, blockaded the vehicle entrance to the Portland ICE facility, trapped officers in their cars, followed them when they attempted to leave the facility, threatened them at the facility, menaced them at their homes, doxed them online, and threatened to kill them on social media,” they said.

The DOJ claimed that federal law enforcement needs the National Guard’s help because they’re “unable with the regular forces to execute the laws of the United States.”

Oregon officials countered that there have been incidents of violence at and near the facility, but that they’ve been small in scale and can continue to be handled local and federal law enforcement.

The DOJ filed an appeal of Immergut’s ruling to the 9th U.S. Circuit Court of Appeals, which is still pending.

The DOJ is facing a similar challenge in Chicago, where a judge last month issued a temporary restraining order barring National Guard troops from being deployed there. The 7th U.S. Circuit Court of Appeals has allowed that order to temporarily remain in effect while the administration’s appeal proceeds.

The administration appealed that ruling to the Supreme Court last month.