The Trump administration plans to cut federal funding from so-called sanctuary cities — a move that could cost the Big Apple an estimated $7 billion.

President Trump vowed to “crack down” on New York and the roughly 300 other cities that protect undocumented immigrants — including Chicago, San Francisco, Newark and New Haven, Conn. — during a speech at Department of Homeland Security headquarters on Wednesday.

His remarks came after he signed an executive order that said, “These jurisdictions have caused immeasurable harm to the American people and to the very fabric of our Republic.”

The order calls for aggressive immigration enforcement and an advocacy office for victims of crimes committed by those in the country illegally.

Relatives of some of those killed or victimized joined Trump.

“Nothing can ever make their pain go away, but I want you to know your children will not have lost their lives for no reason. We will never forget them,” he told them.

Policies differ from city to city, but New York allows undocumented immigrants to use social services without having to disclose their legal status and does not generally cooperate with federal immigration authorities in their deportation efforts.

The NYPD also doesn’t notify the feds about the release of undocumented immigrants who have been arrested and released from custody for minor crimes.

But Mayor Bill de Blasio said the city has a list of roughly 170 criminal offenses that are not covered by the sanctuary policy.

“These are serious offenses, violent crimes. This is the law of New York, has been for years, and it has been the basis for productive cooperation with the federal government. This works,” he said.

The list includes felony assault, rape and murder and terrorism, as well as gun smuggling, witness tampering and patronizing a prostitute, among others.

Hizzoner said that Trump’s plan would undermine public safety, and that if funds from the Departments of Justice and Homeland Security were cut, “We would be in court immediately.”

“President Trump issued an executive order today and its purported purpose was to enhance public safety. But here in New York City and in cities across this nation, this executive order could in fact undermine public safety and make our neighborhoods less safe,” the mayor said.

White House spokesman Sean Spicer said the administration was working on how funds would be cut. “We’re going to strip federal grant money from the sanctuary states and cities that harbor illegal immigrants,” he said. “The American people are no longer going to have to be forced to subsidize this disregard for our laws.”

A report prepared by city Comptroller Scott Stringer in November said that Gotham gets about $8 billion from the feds and could lose roughly $7 billion.

On Tuesday, the mayor proposed a new budget of $84.7 billion that included more money in the city’s reserve accounts in case of federal reductions.