WASHINGTON (Reuters) – Oregon's governor on Wednesday said the federal government agreed to withdraw agents from Portland but the Department of Homeland Security said it would keep officers there until it was certain federal properties would not be attacked.

Governor Kate Brown said the government agreed to a phased withdrawal of federal officers deployed at Portland's Mark Hatfield United States Courthouse after weeks of clashes between activists and agents.

“Beginning Thursday, all Customs and Border Protection and ICE officers will leave downtown Portland, and shortly thereafter will begin going home,” Brown said in a statement.

The U.S. Department of Homeland Security said it agreed on a plan in which state and local law enforcement would begin to secure areas around federal properties and it would change its “force posture” should conditions significantly improve.

“The department will continue to maintain our current, augmented federal law enforcement personnel in Portland until we are assured that the Hatfield Federal Courthouse and other federal properties will no longer be attacked and that the seat of justice in Portland will remain secure,” DHS Acting Secretary Chad Wolf said in a statement.

Republican President Donald Trump, seeking re-election in November, has sought to crack down on protests to highlight his focus on law and order amid unrest across the country after the May 25 killing of a Black man, George Floyd, by Minneapolis police.

The federal government deployed teams of tactical agents to Portland in early July to defend the courthouse, drawing criticism from Democrats and civil liberties groups who alleged excessive force and federal overreach by Trump.

Brown and Portland Mayor Ted Wheeler, both Democrats, complained they never asked for the federal officers and their presence was worsening the situation with protesters.

Solidarity protests spread over the weekend to other U.S. cities, prompting complaints by Democratic mayors that illegal federal deployments were escalating tensions across the country.

Seattle Mayor Jenny Durkan on Tuesday said U.S. Border Patrol Tactical Unit officers had withdrawn from her city.