President Trump heads back to the Oval Office after declaring a national emergency at the U.S.-Mexico border during remarks in the Rose Garden on Feb. 15. (Carlos Barria/Reuters)

In at least 25 different rulings, federal courts have blocked virtually every move President Trump has taken on immigration, with some judges admonishing the administration that the president’s fury over the tide of migrants flowing across the U.S.-Mexico border does not give him the right to skirt acts of Congress or the U.S. Constitution.

The latest defeat came Friday at the hands of U.S. District Judge Richard Seeborg in San Francisco, who blocked Trump’s plan to require asylum seekers to wait in Mexico while U.S. authorities determine their fate. Trump has been on the losing end of at least four other challenges to stem the flow of asylum seekers.

He has sustained four adverse rulings to termination of the Deferred Action for Childhood Arrivals program and at least three to his efforts to end the legal status of immigrants in the United States under temporary protected status due to catastrophes in their home countries.

At least seven courts across the nation have condemned as illegal the administration’s attempt to cut off funds to jurisdictions, dubbed “sanctuary cities,” it deems insufficiently cooperative with the efforts of Immigration and Customs Enforcement to detain undocumented immigrants.

Noting all those setbacks regarding sanctuary cities as she listened to a government lawyer’s appeal in Chicago on Wednesday, Judge Ilana Rovner of the U.S. Court of Appeals for the 7th Circuit despaired.

“Where does this end?” she asked.

Most likely, it doesn’t.

Not since Franklin D. Roosevelt’s efforts to preserve his New Deal programs, perhaps, has a president invested so much in battling the courts on a single issue.

And the administration remains unbowed. It signaled with its housecleaning of the Department of Homeland Security that it’s going to get tougher, with Trump reportedly considering another move that would split up families at the border. He also threatened to close the border with Mexico entirely, even as he faces at least seven lawsuits against his attempt to spend unappropriated money for a border wall through his declaration of a national emergency.

The message Trump is taking from his string of losses — none of which are final — is not that his administration should rethink its legal strategy, but that the Supreme Court will come to his rescue.

“It’s a court system that never, ever rules for us,” he said after his latest loss. But in February, as he discussed his border wall’s fate in the courts, he was confident that “we’ll possibly get a bad ruling, and then we’ll get another bad ruling, and then we’ll end up in the Supreme Court, and hopefully we will get a fair shake.”

The gap between the makeup of the lower courts, still with a majority of Democratic appointees, and the Supreme Court has rarely been so wide.

“I would distinguish between lower courts, where the Trump administration has lost multiple times, and the Supreme Court, where the most recent rulings on immigration upheld the travel ban and took an expansive view of when noncitizens can be detained without bail hearings” in a recent ruling in Nielsen v. Preap , said Emma Kaufman, a University of Chicago Law School scholar who specializes in immigration.

And even if the justices don’t come through as Trump expects, he can blame the judiciary in the 2020 campaign for all that he has not accomplished.

The source of Trump’s discontent on immigration is Congress’s unwillingness to change the laws that he says are permitting migrants to flood across the border. He’s been particularly critical of asylum laws, which he claims allow migrants to “con” the government with bogus claims of persecution in their home countries and then hang around for years in the United States while their cases are adjudicated.

Trump reacted as President Barack Obama did when faced with congressional inaction on immigration. Obama unilaterally deferred deportation for some 4 million law-abiding adults in the country illegally. Obama, too, lost in the courts.

The uniform message from the courts to the administration on asylum is the same as it has been in the cases involving sanctuary cities. The Constitution vests legislative power in Congress, not the president — even when it comes to immigration.

“He’s really pushing the legal edges of what he’s allowed to do,” said Fatma Marouf, a Texas A&M law professor. “Things that are protected by statute, like the right to apply for asylum, Congress has created them, and he can’t just adopt policies that contradict them. . . . There are checks on his power.”

That’s a relatively new development in immigration law, Kaufman said.

“As a whole,” she said, “the lower-court rulings send the message that immigration law is unexceptional — that is, that normal legal rules apply. That’s notable in an area of law that courts have, at least historically, been reluctant to police.”

While it’s hard to match the resources of the Justice Department, Trump’s legal opponents have done it.

The plaintiffs in the cases are migrants, but the organizations running the cases have included coalitions of attorneys general in blue states, big-city legal departments, major universities, the American Civil Liberties Union and other public interest groups, often aided by litigators from major private firms working pro bono.

They’ve achieved success with judges who don’t fit the caricature of “liberal activist” as tweeted earlier this week by White House press secretary Sarah Sanders “

The judge from the Court of Appeals for the 9th Circuit who warned of Trump’s “end-run around Congress” on asylum, for example, was Jay Bybee, a George W. Bush appointee who headed the Justice Department’s Office of Legal Counsel when it issued the “torture memos” during the Bush administration.

Ilana Rovner, who asked “where will it end” in the sanctuary cities case — and added that the issues of separation of powers Trump’s actions raise haunt her dreams each night — was appointed to a district court by President Ronald Reagan and elevated by President George H.W. Bush.

The judges ruling against Trump sit in courts across the country — not just in California, which is often singled out for criticism by the president. Of the 25 immigration-related decisions adverse to Trump, 11 have come from the courts in the vilified 9th Circuit. Eight, by a Washington Post count, have come from the federal courts in the District of Columbia; the others from Pennsylvania, Illinois, New York, Maryland and Massachusetts.

And it was Chief Justice John G. Roberts Jr. who in December declined to join conservatives on the court wishing to lift a lower-court stay of Trump’s policy of denying asylum to those who illegally cross the U.S.-Mexico border. The order stands today as a result.