After previous setbacks to his immigration agenda, President Trump today criticized a federal judge’s ruling Tuesday that the commander in chief cannot retaliate against so-called sanctuary cities by withholding funds, suggesting he’ll take the case to the U.S. Supreme Court.

“First the Ninth Circuit rules against the [travel] ban & now it hits again on sanctuary cities-both ridiculous rulings,” Trump tweeted this morning, referring to his revised travel ban executive order that the 9th Circuit Court of Appeals blocked last month.

Trump added, “See you in the Supreme Court!”

Tuesday’s ruling, from Judge William Orrick, blocks part of Trump’s executive order on immigration enforcement he signed in January that called for “jurisdictions that fail to comply with applicable federal law do not receive federal funds, except as mandated by law.”

Despite Trump’s pointing to the 9th Circuit, Orrick actually sits on the U.S. District Court for the Northern District of California, from which cases are appealed to the U.S. 9th Circuit Court of Appeals.

San Francisco and Santa Clara County filed the lawsuit, arguing that billions of dollars in funding are at risk.

Most sanctuary cities — which include New York City, Los Angeles and Seattle — provide some protections to undocumented immigrants by not fully cooperating with federal immigration authorities.

“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 wrote over two tweets.

“They used to call this ‘judge shopping!’ Messy system,” Trump said, referring to the common practice of filing several of the same lawsuits in hopes of getting a sympathetic judge.

Trump’s tweets echo the White House statement released Tuesday night after the judge’s ruling.

“Today’s ruling undermines faith in our legal system and raises serious questions about circuit shopping,” the statement read. “But we are confident we will ultimately prevail in the Supreme Court, just as we will prevail in our lawful efforts to impose immigration restrictions necessary to keep terrorists out of the United States.”

White House chief of staff Reince Priebus Tuesday night had also called the ruling “an example of the 9th Circuit going bananas.”

ABC News’ Alexander Mallin and Julia Jacobo contributed to this report.