US District Court Judge Michael Mosman said the state lacked standing to sue on behalf of protesters.
Demonstrators have taken to the streets to oppose racial injustice since George Floyd’s death by Minneapolis police two months ago, and many have spiralled into violence.
President Donald Trump condemned the disorder and sent in federal agents early this month to quell the unrest, despite outcry from Democratic leaders in Oregon.
Protesters in Portland have been targeting the federal courthouse, setting fires outside and vandalising the building that US 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 Attorney General Ellen Rosenblum sued the Trump administration last week, alleging federal agents have arrested protesters without probable cause, whisked them away in unmarked cars and used excessive force. US 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 US 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.
Mr Morrell called the protests “dangerous and volatile”