In the wind-swept wilds of southern Mexico, a Beast is stirring.

Migrants heading north are once again taking their chances on the freight train known as La Bestia – so named for the way it maims unlucky riders who fall beneath its wheels as it grinds across the isthmus of Tehuantepec.

Not so long ago, migrants were increasingly seeking safety in numbers, joining mass caravans to travel through Mexico. For a while they encountered an unusually warm welcome, but in recent weeks, the reception has cooled dramatically: police roadblocks have sprung up across the south of the country, and immigration officials have raided migrant camps and broken up caravans.

Evelio Isidro, 23, left Honduras on foot to escape extortionists, and originally planned to walk the length of Mexico after hearing that the government was offering transit visas for Central Americans.

But when the group he was travelling with was targeted by immigration officials – forcing him to run through the hills to escape arrest – he opted instead for the risky train journey.

“President [Andrés] Manuel López Obrador said they weren’t going to detain any migrants so I decided to come,” Isidro said. “But police and immigration officials are detaining and deporting us.”

When he took power in January, López Obrador promised to overhaul immigration policy in Mexico – long feared by Central American migrants as a danger zone of extortion, kidnap and sexual assaults.

The president, known as Amlo, said that Mexico would no longer do America’s “dirty work”, instead offering humanitarian visas allowing migrants to spend one year in the country.

But Donald Trump has derailed those aspirations. The US president has repeatedly accused Mexico of failing to stop migrants and illegal drugs from reaching the US, and is now threatening to slap tariffs on Mexican exports until the issue is resolved.

During his visit to London on Tuesday, Trump reprised the theme, claiming that “millions of people” were being allowed to pass through Mexico, and warning that tariffs could be imposed as soon as next week.

Mexico’s foreign ministry retorted by boasting robust detention and deportation figures: 80,537 people have been repatriated, mostly to Central America, since Amlo took office. López Obrador also wrote to Trump, reminding his US counterpart, “The Statue of Liberty is not an empty symbol.”

But Amlo has acceded to Trump’s “remain in Mexico” policy, forcing nearly 9,000 asylum seekers to stay in Mexico as their cases are heard in US courts. Meanwhile, Mexican immigration officials are taking longer to issue travel documents and caravans are quickly corralled.

“The government is reacting in an extremely hostile way and with [migration] policies which are far from its rhetoric,” said Salva Lacruz, coordinator with the Fray Matías de Córdova Human Rights Centre in Tapachula, near the border with Guatemala.

Mexico has started issuing “regional visas” which allow migrants to freely visit several southern states – far from the US border. But migrants have shown little interest in the poverty-ridden region where wages are little higher than in Central America.

“It’s a tactic to contain Trump’s anger,” Lacruz said of the regional visas. “The Mexican government is under enormous pressure from the United States.”

A volunteer distributes bags of food among migrants as they travel through Mexico to the US on a train known as ‘La Bestia’ in Veracruz state, Mexico. Photograph: Ronaldo Schemidt/AFP/Getty Images

Even amid the crackdown, migrants keep coming: on Tuesday about 400 people crossed the Suchiate River from Guatemala.

Tensions have boiled over in the nearby city of Tapachula, where migrants have staged mass outbreaks from the XXI Century detention centre.

Tuesday’s group was mostly composed of Hondurans, but others passing through the city hail from Cuba, Haiti and African countries.

Many camp out in Tapachula as they wait, living in cockroach-infested flop hotels or sleeping on sheets of cardboard along roadsides.

“My kids have a cold and a cough,” said Kesner Bazin, a Haitian migrant who on a recent afternoon was waiting in the rain outside the migrant center for a transit visa which would give him 20 days to cross Mexico.

He was hoping to reach Tijuana with his family after eight years living in Brazil, but had no idea when the document would be granted. “You have to be patient,” he shrugged.

When the first large-scale caravans passed through the region in late 2018, residents welcomed migrants with open arms, offering weary travellers water, food and clothing.

That help has evaporated and some locals have turned hostile. A group of nuns was handing out food to migrants in Tapachula’s central square, when a passing motorist screamed: “Don’t feed them! Put those lazy fucks to work!”

The nuns feed about 2,500 migrants once a day – rice, beans, eggs and bread – though donations are scarce and local traders often try to gouge prices, said Sister Bertha López, the mother superior.

“There’s a climate of apathy when it comes to helping,” she said.

Officials have turned hostile, too. In Huixtla, up the road from Tapachula, patrol cars have circulated through town, warning over a loudspeaker: “A dangerous caravan is coming.”

“I have to defend my people,” said Huixtla’s mayor, José Luis Laparra, banging his fist on the table before boasting that his police force was “busting the heads” of bad people.

Unsubstantiated stories of migrants committing crimes circulate on social media and create scandalous headlines. “The state [government] and prosecutor’s office doesn’t have any statistics showing crime has increased,” said Sandybell Reyes, migration coordinator with Voces Mesoamericanas, a human rights organisation.

“There’s a stigmatisation of the caravans and all the people coming with them.”

Migration experts say caravans formed so migrants could move openly and avoid the risks of the road through Mexico. Now they warn that, as in previous crackdowns, migrants will be forced to take longer, more risky routes – such as the Beast - to avoid immigration checkpoints.

“They’re more exposed to being robbed, being raped, attacks by organised crime,” said Guadalupe Ramírez, a volunteer at the Brothers on the Road shelter in Ixtepec. “They’re like the perfect target.”