Standing at an improvised barber’s chair in a Catholic-run shelter for Central American migrants in northern Mexico, Ezequiel Romero, 34, cut hair and held court. With banda music blaring in the background, the Honduras native reflected on his reasons for making a long-shot attempt at reaching the United States.

As the owner of a sign business in Honduras, he gave tattooed gangsters $240 to open his business in 2009. Monthly $20 extortion payments—“the war tax”—followed. Then there was the annual “Christmas bonus,” amounting to 15 per cent of sales. Skipping payment wasn’t an option. “The government doesn’t do anything about this,” Romero says, in the city of Saltillo, some 300 km from the Texas border. “They’re colluding with the criminals.”

Romero is among the hundreds of thousands of Central Americans streaming through Mexico, fleeing poverty and violence. Migrants literally risk life and limb to arrive at the U.S. border. The risks of the road include extortion, kidnap, rape and, until recently, riding atop a train known as La Bestia (the Beast), so named for the way it maims migrants who fall under its wheels.

The Mexican government, though, has been trying to stem this flow of migrants—a response to the wave of unaccompanied minors from Central America who made it to the United States in 2014. In the process, Mexico, a country from which millions have fled north over the past half-century in search of better opportunities, has adopted an unlikely role on its southern border: anti-migrant enforcer.

Mexico previously paid little attention to the migrants transiting the country—except for the unscrupulous public officials and crooked cops who preyed on vulnerable Central Americans or acted in cahoots with criminal gangs like Los Zetas, which started kidnapping migrants and demanding ransoms from relatives already living in the United States. But over the past year it has focused on securing its porous southern border, previously a backwater notorious for people floating on rafts across the Suchiate River from Guatemala to Mexico. At the same time that U.S. officials were being swamped with child migrants, Mexico introduced a Southern Border Plan and set about establishing checkpoints, fixing infrastructure in the region and preventing migrants from climbing aboard La Bestia.

The moves might appear sensible, but critics contend the increased enforcement is forcing migrants to try untested routes, away from the system of shelters established to help them. “It was a police operation, not a southern border plan,” says Father Alejandro Solalinde, an activist Catholic priest known for his defence of Central American migrants in the isthmus of Tehuantepec. “The U.S. policy has been: allow in the talent that it wants and stop those that they don’t want in,” Solalinde says. “Mexico is doing this job for them—doing this dirty work.”

The enforcement programs have produced results—at least initially. Figures compiled by the Washington Office on Latin America, a research and advocacy organization, show detentions up 71 per cent between July 2014 and July 2015 (the first full year of the Southern Border Plan), with many of those deported likely to have been eligible to apply for asylum. Alberto Xicoténcatl, director of the Saltillo shelter, says the INM, the government agency that oversees migration, has started using different language, too, calling detentions “rescues,” even though the migrants were not asking for assistance.

The Mexican government insists the program is keeping migrants safe, mainly by preventing them from climbing aboard trains. Still, it’s a radical change in attitudes toward migrants in a country with 11 million citizens living abroad, mostly in the U.S. It’s also seen as ironic in a country that has been quick to denounce demagogues like Donald Trump, who want to deport undocumented immigrants and build a wall on the Mexican border. The southern coordinator with the migrant advocacy group Movimiento Migrante Mesoamericano wrote on Twitter: “[The] Mexican government is carrying out a hunt of Central American migrants, just like @realDonaldTrump plans to do.”

Before he was pushing to close the U.S. border to Muslims, Trump’s main focus of attack was undocumented migrants, promising in November to revive Operation Wetback—a 1950s program of mass deportations (using a word Mexicans consider a slur) aimed at those living without proper documentation in the United States.“You’re going to have a deportation force and you’re going to do it humanely,” Trump told MSNBC. “They’re going back where they came.”

Trump’s comments and the increased enforcement efforts in Mexico come as Mexican emigration is actually collapsing. The number of Mexicans heading north is outnumbered by those returning, with family reunification being the main motive, the Pew Hispanic Center reported in November. The 2008 economic crisis hit Mexicans in the United States especially hard, since so many worked in construction, says Juan José Li Ng, a senior economist at the Mexican bank BBVA Bancomer. A report from the bank posited that Mexicans started staying put due to poor job prospects abroad, the fortification of the U.S. border and anti-migrant initiatives in some states—in effect, a virtual wall.

But Central Americans, it seems, have nothing left to lose. The homicide rate in Honduras tops 80 per 100,000 residents, while El Salvador recently registered 51 murders in a single day—in a country of just 6.4 million people. “I was threatened twice,” says Efraín Pastrana, who fled El Salvador. Gangs “took 20 per cent of my sales. I couldn’t just go to another neighbourhood. They’ll find you there.” “They were asking for the war tax,” equivalent to half of all sales, says Maver Flores, a shopkeeper, who fled Honduras with her four-year-old daughter. The pair were separated while trying to evade an immigration checkpoint near Saltillo, though reunited after days apart, and are now seeking humanitarian visas to stay in Mexico.

Romero, the migrant with the sign business, sees few signs of hope back in Honduras. “I never thought of going to the United States until now,” he says. “It’s because of conditions at home that one emigrates.”

In spite of the enforcement efforts, the operators of shelters for migrants along railway lines running the length of Mexico say the stream of Central Americans shows no signs of stopping or even slowing lately. Figures from the U.S. Customs and Border Protection (CBP) show 10,588 apprehensions of unaccompanied children in the normally tranquil months of October and November, up 106 per cent over the same months in 2014. Detentions of family unit members (minors and those over 18 travelling with them) increased 173 per cent.

The figures suggest Central Americans are figuring out new ways to make it through Mexico. Shelter operators and researchers say the new routes aren’t any easier or safer than riding the rails. Javier Urbano Reyes, who studies migration, says the cost of hiring a “coyote” (a smuggler) has doubled with the increased immigration enforcement. “If Mexicans gave equal treatment to all of its Central American migrants and offered safe transit conditions, they would arrive quicker at the U.S. border,” says Urbano, coordinator of the migration studies program at the Iberoamericana University. “The U.S. doesn’t want this.”

Romero, speaking at the shelter in Saltillo, says his trip was anything but easy. He crossed into Mexico at a remote border crossing in Chiapas state and walked six days through the jungle before reaching the Mayan ruins at Palenque. He later took buses, which some migrants jumped off just before checkpoints to walk circuitous paths to avoid detection. Romero even tried taking La Bestia, but jumped off while it was in motion to avoid arrest. He was robbed of $50 by thugs, too, and saw cops on the lookout for migrants for much of the trip. Asked how he made it so far north, he replies, “I guess that I was lucky.”