Trump suggests he'll take sanctuary cities case to Supreme Court A federal judge ruled that funding may not be withheld from sanctuary cities.

 -- After setbacks to his immigration agenda, President Trump today criticized a federal judge's ruling on Tuesday that the federal government may not retaliate against so-called sanctuary cities by withholding funds, and he suggested that 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, which the 9th Circuit Court of Appeals blocked last month.

Trump added, "See you in the Supreme Court!"

Later today, Trump expressed similar sentiments after signing an unrelated executive order at the Department of Interior.

Asked whether he was surprised by Tuesday's ruling, he said, "I'm never surprised by the 9th Circuit. As I said, we'll see them in the Supreme Court."

The ruling, by Judge William Orrick, blocks part of Trump's executive order on immigration enforcement that he signed in January; it read, "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. Appeals of cases there go to the U.S. 9th Circuit Court.

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 unauthorized 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 wrote, referring to the common practice of filing similar lawsuits in different jurisdictions in hopes of getting a sympathetic judge.

Trump's tweets echo a White House statement released Tuesday night after Orrick'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 on Tuesday night called the ruling "an example of the 9th Circuit going bananas."

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