President Trump has tapped into Americans’ anxiety about illegal immigration by promising to build a wall on our 2,000-mile border with Mexico. However, the vast majority of illegal migrants pouring over our southwest border are from Central America.

The Obama administration’s prescription was pledging billions of dollars in new US assistance, and Congress is considering this. But unless we insist that these nations make their economies more competitive and their institutions less corrupt, we will be pouring good money after bad and failing to stem the tide of immigration at its source.

Less than nine years ago, Bush administration officials spoke of Central American countries as robust economic partners — with which we traded more than with global giants like India. Today, we speak of them as faltering economies that need to be propped up by foreign aid.

El Salvador, Guatemala and Honduras form Central America’s “Northern Triangle,” with economies ravaged by corruption and societies tormented by crime. Millions of poor inhabitants, unable to survive in rural economies, are desperate to find opportunity elsewhere; 60 percent of Guatemalans and Hondurans live in poverty.

Many seek refuge from gang activity and violence fueled by international drug trafficking. Central America accounts for two of the three cities with the world’s highest murder rates. Impunity for criminals remains a serious problem, compounded by widespread corruption and criminal-justice systems that are overwhelmed and underfunded.

Still others were lured by President Barack Obama’s 2012 decision to suspend deportation of “childhood arrivals.” The result was an influx of unaccompanied minors that overwhelmed US authorities on our southwest border in 2014 — creating chaos.

Ironically, while Mexico’s image has paid a price for this border crisis, Mexicans account for a dwindling number of illegal migrants, and, since 2013, Mexican authorities have stopped 560,000 Central Americans making their way to the US border.

During his confirmation hearing, Secretary of State Rex Tillerson stressed the need to address “push factors” in Central America — such as crime and poverty — that drive thousands to make the perilous journey to the United States. Without a doubt, the lack of economic opportunity takes its toll on the region’s youth.

According to the World Bank, one in three young people in Central America neither work nor study. Gangs prey on hopeless youngsters, offering “easy” money or wielding threats to coerce teenagers to join their ranks. Addressing these problems with conventional aid programs is only a temporary solution.

Unless governments are compelled to deal with rampant public corruption, security forces and criminal-justice systems will never resolve the problem. For example, El Salvador is governed by a political party that made clandestine pacts with gang leaders to win elections, and it eavesdrops on rival politicians and private-sector groups.

A principal leader of that party is José Luis Merino — a man suspected of laundering funds for Colombian narco-guerrillas.

In Guatemala, former President Otto Pérez Molina and his vice president left power after their administration was found to be deeply involved in a kickback scheme. Fresh evidence implicating police officials and even a supreme court justice shows the depth and breadth of corruption in that country.

Rigorous congressional and executive-branch oversight is key to discouraging the waste of aid dollars in these Central American countries. But no less important, Congress should impose strict conditions on US assistance.

At a minimum, governments should be required to ferret out corruption. US investigators should support local prosecutors in exposing and punishing corruption.

Equally critical is using US aid to leverage reforms that make these economies more competitive and attractive to foreign investment. So long as the rule of law and economic realities are not respected in these Central American countries, investors will take their dollars elsewhere.

The leftist party that governs El Salvador today has bloated the government payroll, driven up debt and hampered the private economy. As a result, economic growth has been cut in half under the current ruling party.

The United States is a good neighbor. But US taxpayers should not be on the hook for the failures of foreign leaders more interested in holding on to power or using public office for personal gain. We do the people of Central America no favors by ignoring corruption and failed economic policies. And we are missing an opportunity to curb illegal immigration by removing incentives for it.

Roger Noriega is a visiting fellow at the American Enterprise Institute and was a senior US diplomat from 2001-05.