New York City Mayor Bill de Blasio on Wednesday threatened to take the Trump administration to court should they send federal officers to the city amid violence and unrest in recent weeks.

De Blasio, during a press conference Wednesday, said that the federal government seems “fixated” on intervention in the city when city officials do not want the help.

“All over the country, people are distressed but the president’s deep, unwavering desire to send agents all over the country where they are not needed,” de Blasio said, calling it “unproductive.”

De Blasio went on to slam federal intervention in cities like Portland, Ore., as “unconstitutional.”

MAYORS OF PORTLAND, CHICAGO, ATLANTA, OTHER BIG CITIES DEMAND 'FEDERAL FORCES' WITHDRAW

“It’s dangerous,” de Blasio said, noting that the administration is setting a “dangerous precedent of sending in federal officials” and “doing work they should not be doing.”

“We can’t allow it here in New York City or anywhere else,” he continued. “I want to be very, very clear, that we will not allow this to happen.”

De Blasio said he sent a letter to the Department of Homeland Security and Attorney General Bill Barr “making clear” that the presence of federal officers is “not welcome here.”

TRUMP LIKENS DEMOCRAT-LED CITIES TO 'WAR ZONES,' HINTS AT FEDERAL INTERVENTION

“We are New Yorkers and we won’t take lightly if we see federal officers in New York City,” he said. “If we do, we’ll be in court.”

De Blasio’s comments come as President Trump has threatened federal intervention in cities across the nation seeing a spike in violent crime and unrest in recent weeks and months.

White House Press Secretary Kayleigh McEnany on Tuesday slammed de Blasio, and cited a “600 percent surge in violence” in the city, while offering federal support.

“De Blasio seems to have not a hard time criticizing police officers, but an awfully hard time controlling the streets of New York City,” she said.

Last week, Trump likened Democrat-led cities to “war zones,” while hinting federal intervention could be coming.

The president said that the “left-wing group of people that are running cities are not doing the job they’re supposed to be doing.”

Meanwhile, Trump is expected to announce an expansion of the Justice Department’s “Operation Legend” program being run out of Kansas City. Trump, later Wednesday, is slated to announce that the operation will extend to Chicago and Albuquerque.