To listen to most Democrats, they’ve got President Trump on the run when it comes to immigration.

The “big beautiful” wall he promised to build along the border with Mexico hasn’t gone up, and House Democrats will no longer fund even the border-security projects they supported in the past. Federal courts have also been preventing Team Trump from pushing through its efforts to crack down on illegal immigrants, let alone to attempt to fix a broken asylum system gamed by economic migrants from Central America who don’t fit the traditional definition of refugees fleeing for their lives.

But anyone who believes sanctuary-movement backers and Dems seeking to decriminalize illegal immigration are beating the president needs a reality check.

On Wednesday, the Supreme Court ruled to permit the administration to go on refusing to accept applications for asylum from migrants who have passed through another country without being denied asylum there, while a case challenging this common-sense policy works its way through the courts.

That comes on the heels of the court’s decision in July to allow Trump to use money from the defense budget to build the border wall. It was yet another significant victory for the administration’s initiatives and a sign that the left’s judicial guerrilla war that had been stymieing the president is starting to crumble.

Expect liberal efforts to prevent Trump from overturning President Barack Obama’s executive orders that effectively granted amnesty to millions of illegals to meet the same fate.

Fact is, despite the beating Trump has continued to take from the media about government tactics aimed at stemming the surge of illegal immigrants over the southern border, his policies have started to show signs of success.

While no one expects Mexico to pay for Trump’s wall, it is doing something more important: using its resources to stop its people from crossing over into the United States illegally. It has, for example, reinforced security on its southern border and set up checkpoints on highways leading north, dispatching 21,600 police and troops across the nation in the effort.

So far in 2019, the US Border Patrol has arrested more than 400,000 migrants from El Salvador, Guatemala and Honduras for crossing the border illegally. But only 4,300 Mexicans were caught doing so.

It’s all strong evidence that, far from ignoring or rejecting Trump’s efforts to jawbone them into doing something to stop the flood of illegals, America’s most important southern neighbor is listening to him. Recall that Mexico stepped up actions to control the migrants in a bid to avoid tariffs Trump had threatened to impose.

The message has also gotten through to those seeking to come to the United States illegally. Mexican officials have said there has been a “significant decrease” in the number of Central Americans entering their country this year for the purpose of illegally immigrating to the United States.

It makes sense. The campaign by Obama and other Democrats to grant amnesty and a wide array of benefits to illegal immigrants fueled the surge across the border, with new migrants seeking the same lenient treatment. That led to the crisis in which federal resources were overwhelmed by the sheer number of asylum-seekers, prompting much grandstanding and crocodile tears from the left.

Trump’s critics have libelously denounced his attempts to enforce the law — and restore order at the border — as reminiscent of the Nazis and evidence of racism. Yet those efforts seem to be having the intended effect on those contemplating coming here without permission.

With the courts recognizing Trump’s right to use his power to protect the border and with Mexico now cooperating with the United States, perhaps there’s a chance to break the long deadlock over immigration in Washington.

Of course, everyone knows America’s immigration system is badly broken, but Democrats, who hope they will win control of both Congress and the White House next year, have prevented a compromise that would allow the so-called “Dreamers” to stay in the country in exchange for the building of a border wall. So a fix may have to wait until after the 2020 election.

But no matter who wins next year, Trump has shown that, his intemperate rhetoric on the issue not withstanding, strict enforcement policies combined with the help of both the Supreme Court and the Mexicans can provide a way forward to fix an illegal-immigration problem that has long seemed insoluble.

Jonathan Tobin is editor in chief of JNS.org and a contributor to National Review.