President Trump scored a win on Friday, when a federal appeals court gave a temporary green light to his Remain-in-Mexico program. The idea is to keep asylum seekers south of the border until they get their day in court. It’s urgently needed to help border towns like McAllen, Texas, in the Rio Grande Valley region, and Las Cruces, New Mexico, which are being overwhelmed.

The same critics pouncing on Trump’s call to transport these asylum seekers to sanctuary cities are also opposing his Remain-in-Mexico program. For these Trump-haters, nothing matters but politics. They have no real interest in providing relief to the border towns, American taxpayers or migrants caught in the chaos.

More than 100,000 migrants, including a record number of families with children, were apprehended sneaking across the border in March, many claiming asylum. The border towns are dumping grounds for them once they’re released from detention facilities.

They lack food, shelter and the ability to speak English. Las Cruces city officials put out a call on Saturday for donated blankets, clothing, food and diapers. Shelters and churches are full, bus stations chaotic, charities tapped out. McAllen Mayor James Darling begged for a “solution that does not involve simply dropping them off onto the streets of our city.”

But like every option Trump has tried, including detaining migrant families in shelters until their claims are heard, the Remain-in-Mexico program is being challenged by a cadre of open-borders lawyers. The program’s future hinges on a ruling by the Ninth Circuit Court of ­Appeals later this week and perhaps a final decision by the US Supreme Court down the road.

In the meantime, migrants scrape together bus fare to escape the mess. If they don’t have family already here, they pick a destination they’ve heard is immigrant-friendly. Word spreads fast about which communities will welcome asylum seekers, house them and shield them from immigration enforcement. These tend to be liberal localities.

For example, Portland, Maine, offers migrants cash welfare, housing and job training. The city is also considering letting illegal migrants vote in local elections. That information has traveled all the way to McAllen’s shelters. Migrants hear Portland is the place to go.

Now that Portland’s shelters are overflowing, the same city politicians who boast about welcoming migrants whine that Portland shouldn’t bear the cost. Portland wants all of Maine to pay. Lesson: It’s easy to be big-hearted using somebody else’s money.

Cost is behind a lot of the opposition to Trump’s sanctuary-city proposal. San Francisco Mayor London Breed denounced Trump’s proposal as “just another scare tactic,” implying that anyone opposed to busloads of migrants must be a racist.

But race isn’t the issue. What’s actually scary is the cost of sheltering busloads of needy people.

As left-wing icon Cher tweeted Monday, “I Understand Helping struggling Immigrants, but MY CITY (Los Angeles) ISNT TAKING CARE OF ITS OWN.”

And why should taxpayers foot the bill, when only about 10% of migrants from Central America actually qualify for asylum? The rest are scammers, economic migrants trying to take advantage of refugee protections.

They sneak across the border, tell a border agent they’re afraid to return and get released inside the US. Half never even complete an asylum application. They’ve gotten what they want, jumping ahead of those who wait years to enter legally.

Word about how to game the system has spread, and now migrants are coming through the southern border from as far as Angola and the Congo.

One Texas resident asked why “non-border states” can’t “help support” the immigrants with free emergency room services, schooling and other costly benefits.

Truth is, towns across the US ­already doing that are strained by the costs. Trump’s Remain-in-Mexico program is designed to alleviate that problem. The more asylum-seekers Mexico shelters, the more money stays in taxpayers’ pockets.

So far only a few hundred have been returned to Mexico. Litigation stalled the effort.

Fortunately, the Supreme Court has twice recognized a president’s authority to limit who enters the country, including under the guise of asylum. Trust the high court to uphold Remain-in-Mexico, bringing relief to border towns and US taxpayers everywhere.

Betsy McCaughey is a former lieutenant governor of New York.