By law and custom, the power to regulate immigration resides in Washington, even when Donald Trump is president, and even when ­Andrew Cuomo is governor of New York.

Hence why US Attorney General William Barr is now moving against a particularly ugly challenge to federal immigration primacy. Good for him.

And even Cuomo, usually so combative on the issue, seems to get it: He is traveling to Washington Thursday, apparently to concede the point to Trump face-to-face.

At issue is the so-called sanctuary movement, whereby states and localities that have embraced progressive contempt for the law declare themselves to be exempt from its reach, and then start to act that way. They refuse to cooperate with federal immigration officers, often obstructing deportations of criminal aliens and otherwise hamstringing enforcement efforts.

Innocent people pay the price for such interference, including 92-year-old Maria Fuertes of Queens, raped and murdered last month allegedly by a man set free by the NYPD despite an Immigration and Customs Enforcement request that he be held for deportation. Barr noticed this.

“Local police in New York City had the alien in custody,” said Barr Monday, but they “ignored the [ICE] detainer, so the alien was released into the streets, and then last month he allegedly raped and murdered … Feurtes, affectionately known as ‘abuelita,’ a fixture in her neighborhood.”

So where’s the justice there? There is none, of course — and Barr has had enough.

“So-called ‘progressive’ politicians are jeopardizing the public’s safety by putting the interests of criminal aliens before those of law-abiding citizens,” continued Barr. “Their express purpose is to shelter aliens whom local law enforcement has already arrested for other crimes. This is neither lawful nor sensible.”

That should go without saying. But common sense long ago fell victim to the culture wars, which explains why some states, ­including Cuomo’s New York, won’t even allow ICE routine ­access to hitherto public motor- vehicle records.

Across-the-board immigration obstructionism is why the Justice Department filed suit against three of America’s more egregious sanctuary offenders — New Jersey, California and King County in Washington state. If they won’t comply with the law as an obligation of constitutional order, then they will be forced to do so under threat of federal-court sanctions.

Similarly, the Department of Homeland Security last week ­expelled New York from its so-called Global Entry and related expedited-travel programs: Access to DMV records is necessary for the expedited-travel programs to work — so, no access to New York records, no programs for New Yorkers. What could be more commonsensical than that?

Reaction was swift and predictable. Cuomo accused Trump of using immigration “as a wedge to divide the body politic and give them a simple answer to all their problems: It’s immigration.” With that simplistic analysis, the governor announced a lawsuit to counter the Global Entry expulsion.

The activist left piled on. “States in various ways are deciding not to be arms of the government’s deportation machine,” said Omar Jadwat of the America Civil Liberties Union. “DOJ, instead of looking at why that is, has decided to go after the states.”

Actually, it is crystal clear why that is: Some states, along with many offending subdivisions, are in open defiance of the law, creating local crime crises and presenting an unnecessary threat to national security.

And so the Trump administration acted — taking overdue, if so far tentative, steps to bring the nonsense to an end. Hurrah and hallelujah!

Cuomo, ever the weathervane, seems to recognize the weakness of his position. Thousands upon thousands of New Yorkers ­depend on the expedited-travel programs, and their patience, should progressive posturing disrupt them, is likely to be thin.

Thus did the governor say he’ll be bending a knee before Trump Thursday — he didn’t put it quite that way, of course — in an effort to secure a “compromise” ­regarding the feds and DMV records. He isn’t likely to get one without some squirming — what a delicious image that is — but there’s no legitimate reason for Trump even to consider one. Nor should Barr waver.

Sanctuary policies offend reason, undermine respect for the law, disrupt civil tranquility and endanger innocent people.

End of discussion.

Twitter: @RLMac2