People stand in line at a visa-processing office in Durango, Mexico. (Luis Antonio Rojas for The Washington Post)

President Trump is threatening to shut down the U.S. border with Mexico because the country “refuses to help with illegal immigration.”

The reality is much more complicated.

Mexico actually works closely with the U.S. government on irregular migration. Mexico deports thousands of immigrants each month, most from Central America. That’s continued under a new leftist president who has promised more humane policies on migration.

Authorities have announced plans to deploy security forces to a “containment” belt north of the Guatemalan border.

Last year, they even agreed to host migrants who are applying for asylum in the United States while their cases wend their way through the U.S. courts.  

Data from the first three months of President Andrés Manuel López Obrador’s administration shows little change in detentions from the same period a year earlier. Mexican officials detained 25,483 migrants in the three months that began in December 2018, according to the University of Texas’s Mexico Security Initiative, down only slightly from the 27,455 detained during the same three-month period the year before.

The problem is, there appear to be far more migrants crossing the country. That’s evident at the U.S. border, where detentions are soaring.

“U.S. apprehensions have doubled, suggesting the number of people crossing through Mexico doubled,” said Stephanie Leutert, director of the Mexico Security Initiative.

The percentage detained by Mexico, in other words, has dropped.

There appear to be a variety of reasons for the decline.

One is that Mexican authorities might simply not be organized to handle the surge.

“It’s a question of institutional capacity,” said Gustavo Mohar, a former top Mexican intelligence and immigration official.

Illegal immigration is handled by Mexico’s National Migration Institute.

“But the Migration Institute has very few resources,” Mohar said. “It has few personnel.”

Another problem is the arrival of migrants from Central America over the past year in caravans of thousands.

Mexican authorities initially let them cross the country. As the migrants attracted global media coverage, officials apparently feared that rounding them up would bring criticism — or lead to bloodshed.

The Mexican government initially “thought it was only going to be a caravan or two,” Mohar said. “But the signal they sent encouraged people,” he said, and more caravans formed.

Under López Obrador, authorities issued thousands of humanitarian visas to the migrants, allowing them to stay and work in Mexico. The program drew an overwhelming response, and authorities shut it down in late January. Many of the migrants used the visas to travel to the U.S. border.

Mexico is now trying to design a system in which would-be migrants would apply for humanitarian visas in their home countries. It’s expected to launch in May.

In the meantime, authorities announced that they would provide humanitarian visas starting Monday to some of the 2,500 migrants currently in the southern state of Chiapas, giving priority to women, children and the elderly. Most will probably receive visas because they are in families traveling together. 

López Obrador said Monday that Mexico was helping to control the migrants’ passage. 

“We have to establish order in this migratory flow so that it is legal and, at the same time, human rights are protected,” he told a news conference.

Mexico is taking other steps to restrict irregular migration. Interior Minister Olga Sánchez Cordero announced recently that authorities would deploy security forces to form a containment belt across the Isthmus of Tehuantepec, Mexico’s narrowest point, about 200 miles north of the Guatemalan border.

Mexico’s most audacious step might be its agreement to become a sort of waiting room for migrants as they go through the process of seeking U.S. political asylum. That’s part of a Trump administration program known as the Migration Protection Protocols.

“This is a radical change in Mexican foreign policy,” said Jorge Durand, an immigration expert at the University of Guadalajara. 

One area where Mexico hasn’t had much success is in reducing the corruption that allows smugglers to move thousands of people through the country. Smugglers have taken to using express buses to whisk migrants to the border, apparently with the complicity of some police and immigration officials, analysts say.

The buses “are facilitated completely by corruption,” said Leutert.