NEW YORK (CBSNewYork/AP) — President Donald Trump is vowing to take his fight to the highest court, calling the decision by a federal judge to block an executive order to withhold funding from so-called sanctuary cities as “ridiculous.”

U.S. District Judge William Orrick issued the temporary ruling Tuesday in a lawsuit over the executive order targeting sanctuary cities, including New York. The decision will stay in place while the lawsuit moves through court.

“First the Ninth Circuit rules against the ban & now it hits again on sanctuary cities-both ridiculous rulings,” the president said on Twitter Wednesday morning. “See you in the Supreme Court!”

Trump signed the executive order on Jan. 25 to cut federal funding to cities that don’t cooperate with with U.S. immigration authorities.

But Orrick said in his ruling that the president cannot set new conditions on spending approved by Congress. He rejected the administration’s argument that the executive order applies only to a relatively small pot of money.

Even if the president could do so, those conditions would have to be clearly related to the funds at issue and not coercive, as the executive order appeared to be, Orrick said.

“This is why we have courts,” San Francisco City Attorney Dennis Herrera said. “To halt the overreach of a president and an attorney general who either don’t understand the Constitution or choose to ignore it.”

The administration has often criticized the 9th U.S. Circuit Court of Appeals. Orrick does not sit on that court but his district is in the territory of the appeals court, which has ruled against one version of Trump’s travel ban.

“Out of our very big country, with many choices, does everyone notice that both the ‘ban’ case and now the ‘sanctuary’ case is brought in …the Ninth Circuit, which has a terrible record of being overturned (close to 80%),” Trump said in a series of tweets. “They used to call this ‘judge shopping!’ Messy system.”

The ruling comes as Attorney General Jeff Sessions has a planned visit to Central Islip to meet with prosecutors to discuss the MS-13 gang problem.

“Half of murders in New York are gang-related with illegal immigrants involved,” he said. “Why would you not want to deport them and make the city even safer?”

Last week, the Department of Justice sent a letter to New York and other sanctuary cities across the country, demanding they prove they were working with immigration authorities.

The Trump administration says sanctuary cities allow dangerous criminals back on the street and that the order is needed to keep the country safe.

Mayor Bill de Blasio argues the city has never been safer. Wednesday morning, de Blasio said on Twitter that “Trump’s order would drive police and communities apart. It’s building that relationship that made New York the safest big city in America.”

On Tuesday de Blasio said Trump was “going beyond his authority when he tries to cut vital funding to cities that don’t share his illogical and unconstitutional desire to scapegoat immigrants.”

White House Press Secretary Sean Spicer’s office slammed the decision in a statement as an “egregious overreach by a single, unelected district judge.”

He adds that the ruling is “a gift to the criminal gang and cartel element in our country” and claims it puts “thousands of innocent lives at risk.”

Orrick’s ruling was another immigration policy setback for the administration as it approaches its 100th day in office later this month. The sanctuary city order was among a flurry of immigration measures Trump signed in January, including a ban on travelers from seven Muslim-majority countries and a directive calling for a wall on the Mexican border.

The Department of Justice said Tuesday that it will continue to enforce a federal law that forbids communities from blocking reports on people’s immigration status to federal authorities.

The department said it will also enforce existing conditions on federal grants that require compliance with that law.

(© Copyright 2017 CBS Broadcasting Inc. All Rights Reserved. The Associated Press contributed to this report.)