A riot was declared in Portland just after midnight Thursday morning after Mayor Ted Wheeler’s tense visit with protesters-- where he was booed, told to resign, given a list of demands and tear-gassed by federal agents.

His visit ended with his security detail engaging in a struggle with protesters late Wednesday night as they worked to get the mayor to safety, a report said.

Earlier, he moved with protesters to the fence outside of the federal courthouse where he stood at the front and was tear-gassed along with the crowd, according to New York Times correspondent Mike Baker.

Wheeler called the tear-gassing an "egregious overreaction," telling Baker he didn't see anything in the crowd that warranted the reaction by federal officers.

"This is not a de-escalation strategy," he said. "This is flat-out urban warfare and it's being brought on this country by the president and it's got to stop now."

PORTLAND BANS POLICE FROM WORKING WITH FEDERAL LAW ENFORCEMENT 

As Wheeler left, a few protesters following him tried to push against his security team once he had entered a building. Others threw water bottles and other projectiles at the glass door, according to Baker.

Portland's City Council passed new policies on Wednesday that immediately bans all police bureau members from working with federal law enforcement and prevents them from intentionally arresting or using force on journalists and legal observers.

Wheeler had joined protesters downtown earlier in the evening for a listening session where he thanked them for opposing the Trump administration’s “occupation” of the city in the deployment of federal agents.

"I think what we're doing tonight is actually the best thing we can do right now," Wheeler told hundreds in the crowd after a protester asked how to get federal officers out of the city, according to KGW-TV. "Be here, be heard, be unified, and be clear. We didn't want them, we didn't ask for them, they're not trained for what they're being asked to do. And we want them to leave."

Hundreds of Black Lives Matter protesters rally near the Mark O. Hatfield United States Courthouse on Tuesday, July 21, 2020, in Portland, Ore. (AP Photo/Noah Berger)

Hundreds of Black Lives Matter protesters rally near the Mark O. Hatfield United States Courthouse on Tuesday, July 21, 2020, in Portland, Ore. (AP Photo/Noah Berger)

Wheeler, who has repeatedly said he opposes the deployment of federal officers to the city, was nearly drowned out by shouts and jeers and calls to resign and was loudly booed when he told a protester that he didn’t support abolishing the police department.

He then addressed a much larger crowd from a raised balcony, saying “I am here tonight to stand with you.” He received some cheers when he chanted “Black lives matter!” with the crowd.

Some protesters also threw fireworks at the courthouse and tried to knock down the fencing erected outside.

CLICK HERE TO GET THE FOX NEWS APP

Wheeler, who is also the police commissioner, has been accused by some of not reining in local police, who have used tear gas multiple times before federal agents arrived early this month in response to nearly two months of nightly protests since George Floyd was killed. Others, including business leaders, have condemned Wheeler for not bringing the situation under control before the federal agents arrived.

The mayor's office did not immediately respond to Fox News' request for comment.

Fox News' David Aaro and the Associated Press contributed to this report.