Hours after the president signed an executive order on Wednesday stripping federal grant money from “sanctuary” states and cities, Mayor Bill de Blasio promised he would take Donald Trump to court if he tried to take federal funding away from NYC.

De Blasio and other elected officials have proudly touted the city’s long-standing position of protecting undocumented immigrants from legal repercussions.

During an evening news conference at City Hall, de Blasio said the executive order is vague, but would likely affect the NYPD more than any other city agency, and most specifically affect anti-terrorism funding. He said he does not believe the executive order could be implemented in a broad way.

“If anything actually starts to move, the city of New York will take legal action to stop the executive order from hurting our city and our people. If that were ever attempted we would be in court immediately to stop it, and I know that will happen in cities all over the country, he said.

“I think that the president and his team are going to have to look long and hard at the notion of taking away anti-terrorism funding from New York City, taking away funding that protects foreign leaders who visit New York City, and taking away funding that protects Trump Tower and everyone who works in it and lives in it and visits it.”

Hundreds of protestors also gathered in Washington Square Park in an "emergency" rally organized by CAIR New York, on Wednesday, chanting, "Say it loud, say it clear, refugees are here to stay." They also blasted the Trump administration as "too male, too pale and too stale."

"We reject policies that turn their backs on those who have suffered," U.S. Representative Nydia Velazquez (D-Manhattan/Brooklyn/Queens) shouted to protesters.

If the executive order is acted upon, the city stands to lose “anywhere between $150 and $160 [million]” in federal funding, Police Commissioner James O’Neill said, for things like anti-terrorism intelligence. To a lesser extent, de Blasio said, funding for the Department of Correction could be affected.

O’Neill said part of the reason crime is down in New York is the focus on neighborhood policing.

“The goal there is to keep New Yorkers safe, but it’s also to build trust. I wouldn’t want to do anything to put that at risk,” he said. “There’s a very delicate balance in New York City right now that’s why we’re doing so well.”

De Blasio said the city already works to deport those who commit 170 different categories of serious or violent crimes. He said he mentioned this to Trump and Attorney General nominee Jeff Sessions when they met at Trump Tower in November.

“This works. It has been working. It’s helped to keep us safe without undermining the relationship between our police and our communities,” the mayor said about the list of offenses. “This will continue, but we will not deport law abiding New Yorkers. We will not tear families apart. We will not leave children without their parents.”

On Tuesday, de Blasio said the city has no plans to compensate for federal funding cuts, but that the city has put aside about $1 billion in reserves and directed agencies to find another $500 million in savings in about three months.

City Council Speaker Melissa Mark-Viverito didn’t mince words in her reaction, calling Trump a “highly insecure individual,” but urging de Blasio to cushion his proposed $84.7 billion budget in anticipation of looming funding cuts.

“We’re not going to stand idly by while the Trump administration tears families apart and uses them as scapegoats,” she said while speaking at a separate engagement, adding moments after watching Trump speak on television: “Utilizing families and their pain, and using undocumented immigrants, and putting them all in one lump-sum category, and vilifying them as criminals is obviously a false narrative that he continues to hold up and is very dangerous and divisive to this country.”

Attorney General Eric Schneiderman said if Trump does not revoke the executive order, he will fight it.

“The president lacks the constitutional authority to cut off funding to states and cities simply because they have lawfully acted to protect immigrant families ... Local governments seeking to protect their immigrant communities from federal overreach have every right to do so,” Schneiderman said in a statement. “Any attempt to bully local governments into abandoning policies that have proven to keep our cities safe is not only unconstitutional, but threatens the safety of our citizens.”

Earlier this month, City Comptroller Scott Stringer released a report showing that immigrants make up about 46% of the city’s workforce and immigrant families contribute about $8 billion in city and state personal income taxes.

“There is critical federal funding at stake for New York City,” he said in a statement on Wednesday. “Either the White House doesn’t understand the significance of its threats to defund sanctuary cities, or it does and is willfully turning its back on America’s legacy as the land of freedom and opportunity for all.”

While the city stands to lose millions, Joseph Giacalone, a retired NYPD detective who lectures at John Jay College of Criminal Justice, said he doesn’t see how the department could cut back on security.

“It’s not going to affect the security at all because the NYPD has an obligation to ensure not only the regular citizens but the president of the United States in a White House on Fifth Avenue. They have no choice,” he said. “Whatever the bill is going to be, they’re going to have to suck it up. If the city gets the money or not, they’re going to figure out how to do it.”

The city has fronted $37.4 million for NYPD security around Trump Tower. So far, Congress has offered $7 million in reimbursement. It was not immediately clear how exactly the executive order would affect security around Trump Tower.

If New York remains a sanctuary city, Giacalone said cops will continue to do whatever is asked of them, including not asking someone’s immigration status.

“Cops will do what they’re told,” he said.

Christina Greer, an assistant professor of politics at Fordham University, said the city will have a rough road ahead, but was confident de Blasio will stand his ground.

“Losing that money affects priorities, but I feel like we have a mayor who says if it’s our money and our principles, let’s go our principles,” she said, noting New York could serve as an example for other sanctuary cities around the country. Other sanctuary cities include Chicago and Los Angeles.

Jonathan Bowles, the executive director of the Manhattan think tank, Center for an Urban Future, agreed.

“I don’t think that New Yorkers will allow Trump to divide us on this issue,” Bowles said. “This will be an important rallying cry for New Yorkers. They will stand with immigrants.”

Trump also signed a second executive order on Wednesday to build a wall along the U.S. border with Mexico.

-With Matthew Chayes and Reuters