The Trump administration is planning to withdraw some federal security forces from Portland, Oregon, after weeks of clashes with protesters.

US Homeland Security Secretary Chad Wolf said the pullout was conditional on local police protecting federal buildings, the focal point of unrest.

Oregon Governor Kate Brown said federal agents would start leaving the state's biggest city from Thursday.

Portland has been rocked by 62 consecutive days of demonstrations.

What did federal and state officials say?

In his statement, the US homeland security secretary set no timeline for a pullout. 

But he said he and the governor had "agreed to a joint plan to end the violent activity in Portland directed at federal properties and law enforcement officers".

"That plan includes a robust presence of Oregon State Police in downtown Portland."

He added that "state and local law enforcement will begin securing properties and streets, especially those surrounding federal properties, that have been under nightly attack".

The governor tweeted on Wednesday: "They have acted as an occupying force & brought violence. Starting tomorrow, all Customs and Border Protection & ICE officers will leave downtown Portland."

But she added that federal officers from the US Marshals Service and Federal Protective Service will stay at the courthouse, where they are usually based.

Following the announcement, President Trump, a Republican, declared victory, tweeting: "If the Federal Government and its brilliant Law Enforcement (Homeland) didn't go into Portland one week ago, there would be no Portland.

"It would be burned and beaten to the ground. If the Mayor and Governor do not stop the Crime and Violence from the Anarchists and Agitators immediately, the Federal Government will go in and do the job that local law enforcement was supposed to do!"

Hours after the announcement on Wednesday night, hundreds of protesters gathered in the city centre near the courthouse building.

What happened in Portland?

The security forces were sent there on 4 July to protect federal buildings that were vandalised during weeks of protests against racism and police brutality following the death of George Floyd, an unarmed black man, in Minneapolis, Minnesota, in May.

Their deployment exacerbated the civil unrest, especially when footage emerged of demonstrators being grabbed off the street by federal officers and forced into unmarked cars.

The governor and Portland Mayor Ted Wheeler, both Democrats, complained they never asked for the federal intervention, blasting it as an election-year stunt by the US president.

The Mark O Hatfield Federal Courthouse in the city centre has become a nightly battleground, with both federal officers and demonstrators injured in bloody confrontations.

According to oregonlive.com, medics, journalists and legal observers have also been hurt by rubber bullets and pepper balls fired by the federal officers.

In tandem with the crackdown in Portland, the Trump administration has sent in federal agents to several Democratic-run US cities rocked by rising gun crime: Chicago, Kansas City and Albuquerque.

The US Department of Justice said on Wednesday it would also send federal officers to three more Democratic-run US cities - Cleveland, Detroit and Milwaukee - owing to "disturbing increases in violent crime, particularly homicides". BBC