Mexico won’t have to pay for the wall, after all. US taxpayers won’t have to pick up the tab, either. The controversial barrier, rather, will cover its own cost just by closing the border to illegal immigrants who tend to go on the federal dole.

That’s the finding of recent immigration studies showing the $18 billion wall President Trump plans to build along the southern border will pay for itself by curbing the importation of not only crime and drugs, but poverty.

“The wall could pay for itself even if it only modestly reduced illegal crossings and drug smuggling,” Steven A. Camarota, director of research at the Center for Immigration Studies, told The Post.

Federal data shows that a wall would work. A two-story corrugated metal fence in El Paso, Texas, first erected under the Bush administration has already curtailed illegal border crossings there by more than 89 percent over the five-year period during which it was built.

Absent a wall, the Homeland Security Department forecasts an additional 1.7 million illegal crossings at the US-Mexico border over the next decade.

If a wall stopped just 200,000 of those future crossings, Camarota says, it would pay for itself in fiscal savings from welfare, public education, refundable tax credits and other benefits currently given to low-income, illegal immigrants from Mexico and Central America.

If a wall stopped 50 percent of those expected crossings, he says, it would save American taxpayers a whopping $64 billion — almost four times the wall’s cost — to say nothing of the additional billions in federal savings from reduced federal drug interdiction and border-security enforcement.

Camarota explains that illegal border-crossers from Mexico and Central America — who account for more than 75 percent of the illegal immigrant population in the US — are overwhelmingly poor, uneducated and lack English language and other skills. In fact, the average Latino illegal immigrant has less than a 10th-grade education. That means if they work, they tend to make low wages; and as a result pay relatively little in taxes while using public services. And if they have children while in the US, they more often than not receive welfare benefits on behalf of those US-born children, who have the same welfare eligibility as any other citizen.

“A large share of the welfare used by immigrant households is received on behalf of their US-born children,” Camarota said. “This is especially true of households headed by illegal immigrants.”

Therefore, illegal border-crossers create an average fiscal burden of more than $72,000 during their lifetimes, Camarota says. Including costs for their US-born children, the fiscal drain jumps to more than $94,000.

While the national media routinely report that illegal immigrants don’t go on welfare, Camarota says this is a pervasive myth. While in most cases they can’t legally qualify for welfare, food stamps, Medicaid or other public benefits, the reality is that the vast majority of households headed by illegal immigrants are on welfare through their children.

The vast majority of households headed by illegal immigrants are on welfare through their children.

“There is simply no question that households headed by illegal immigrants access a good deal of welfare. In fact, illegal immigrants’ use of some programs is quite high,” he said.

The US Census Bureau’s latest “survey of income and program participation” shows that 62 percent of illegal-immigrant-headed households are on the federal dole — more than double the rate for households headed by native-born Americans. And that includes households where one or more workers are present in the household.

Their use of US welfare is highest for food stamps and Medicaid, data show.

Though welfare use among illegal immigrants is much more associated with children, “childless illegal households still use some welfare programs at surprisingly high rates,” Camarota pointed out.

Some collect federal benefits through fraud or administrative errors or through green-card holders. But in the case of Medicaid, pregnant women illegally in the country can sometimes be enrolled in the program.

There is also an Emergency Medicaid program that covers predominantly illegal immigrants. Funds from the multibillion-dollar program go to hospitals to offset the cost of treating adult illegal aliens who can’t pay their bills. And it’s not just for ER visits. In New York, the program can be used to provide chemotherapy and radiation therapy for illegal immigrants.

In addition, Camarota said the IRS each year pays out billions to illegal immigrants in refundable child tax credits and the earned income tax credit.

While Democrats complain the $18 billion price tag for the Trump wall is too high, the “Dreamers” amnesty bill they want Trump and Republicans to pass in exchange for funding the wall (or ideally in spite of the wall) would cost US taxpayers even more than the construction of the border partition over 10 years.

“The cost of the DREAM Act has been estimated as very large — a $26 billion net cost in the first 10 years,” Camarota noted.

Indeed, the Congressional Budget Office recently estimated that 3 million DREAM Act recipients would receive an estimated $12 billion-plus in ObamaCare subsidies, more than $5.5 billion in Medicaid benefits, $5.5 billion in earned-income and child-tax credits and more than $2 billion in food stamps.

A bipartisan bill incorporating the deal was defeated in the Senate last month by a vote of 54-45. Trump rejected the proposal in favor of a tougher border bill introduced by Sen. Chuck Grassley (R-Iowa), which limits the number of DACA beneficiaries to 1.8 million, curbs family visas, or so-called chain migration, and phases out the diversity visa lottery, while earmarking $25 billion in funding for the wall and other border security.

Sperry is a former Hoover Institution media fellow. Follow him on Twitter: @paulsperry_