PORTLAND, Ore. — A U.S. judge Friday denied an order sought by Oregon’s attorney general to stop federal agents from arresting people during nightly protests in Portland that have roiled the progressive city and pitted local officials against the Trump administration.

U.S. District Judge Michael Mosman said the state lacked standing to sue on behalf of protesters.

Demonstrators have taken to the streets to oppose racial injustice and police brutality since George Floyd’s killing by Minneapolis police two months ago, and the protests have sometimes spiraled into violence. President Trump in response sent in federal agents early this month, despite outcry from Democratic leaders in Oregon.

The clash has further inflamed the nation’s political tensions and triggered a crisis over the limits of federal power in states as Trump moves to send U.S. officers to other Democratic-led cities. It’s playing out as Trump pushes a “law and order” reelection strategy.

Protesters in Portland have been targeting the federal courthouse, setting fires outside and vandalizing the building that U.S. authorities say they have a duty to protect. Federal agents have used tear gas, less-lethal ammunition that left one person critically injured and other force to scatter protesters, and they have made arrests.

Oregon Atty. Gen. Ellen Rosenblum sued the Trump administration last week, alleging that federal agents have illegally arrested protesters without probable cause, whisked them away in unmarked cars and used excessive force. U.S. authorities deny those accusations.

She sought a temporary restraining order to “immediately stop federal authorities from unlawfully detaining Oregonians.”

David Morrell, an attorney for the U.S. government, called the motion “extraordinary” and told the judge in a hearing this week that it was based solely on “a few threadbare declarations” from witnesses and a Twitter video. Morrell called the protests “dangerous and volatile.”

Before the aggressive language and action from federal officials, the unrest had frustrated Mayor Ted Wheeler and other local authorities, who had said a small cadre of violent activists were drowning out the message of peaceful protesters. But the Democrat says the federal presence is exacerbating a tense situation and he’s repeatedly told them to leave.

Wheeler, who was tear-gassed as he joined protesters this week, has faced opposition from all sides, for not bringing the protests under control before federal officers arrived and for standing by as Portland police used tear gas and other tactics.

Acting Homeland Security Secretary Chad Wolf denied that federal agents were inflaming the situation in Portland and said Wheeler legitimized criminality by going to the front of the crowd of demonstrators where fires were lighted and people were trying to pull down the protective fence.

Trump has called protesters “agitators & anarchists.” With less than four months until election day, he has claimed that violence will worsen if his Democratic rival, Joe Biden, is elected in November and Democrats have a chance to make the police reforms they have endorsed since Floyd’s death.

In the lawsuit, Oregon had asked the judge to immediately command agents from the U.S. Department of Homeland Security, the Customs and Border Protection, the Federal Protective Service and the Marshals Service to stop detaining protesters without probable cause, to identify themselves before arresting anyone and to explain why an arrest is taking place.

The action comes as U.S. agents have arrested 18 people in Portland this week as the clash with protesters turned chaotic for another night.

The number doesn’t include arrests made early Friday, when federal officers again used tear gas to force thousands of demonstrators from crowding around a U.S. courthouse, a target of two months of nightly protests. Protesters projected lasers on the building and tried to take down a security fence. They scattered as clouds of gas rose up and agents fired crowd control munitions, which critically injured a demonstrator this month.

The protesters who were arrested face federal charges including assaulting federal officers, arson and damaging federal property, U.S. Atty. Billy J. Williams said. All the defendants are local, and they were released after making a court appearance.

U.S. officers “working to protect the courthouse have been subjected to nightly threats and assaults from demonstrators while performing their duties,” according to a statement from Williams’ office.

Wolf previously said 43 federal arrests had been made as of Tuesday.

The Oregon attorney general’s motion was one of several lawsuits against authorities’ actions. A different federal judge late Thursday blocked U.S. agents from arresting or using physical force against journalists and legal observers at demonstrations.

U.S. Judge Michael Simon had previously ruled that journalists and legal observers are exempt from police orders requiring protesters to disperse once an unlawful assembly has been declared. U.S. lawyers intervened, saying journalists should have to leave when ordered. He said 1st Amendment concerns held more sway than law enforcement objections.

“None of the government’s proffered interests outweigh the public’s interest in accurate and timely information about how law enforcement is treating” protesters, Simon wrote. His order is in effect for two weeks.

Meanwhile, the Justice Department’s inspector general says it will review the conduct of agents who were deployed against protesters in Portland and in Washington, D.C., after concerns emerged from members of Congress and the public.