CIUDAD HIDALGO, Mexico — Hundreds of Central American migrants who waded across a river into Mexico in hopes of eventually reaching the U.S. were sent back to their homeland or retreated across the border Tuesday after Mexican troops blocked their way.

Fewer than 100 remained in the no-man’s-land along the river between Guatemala and Mexico.

The caravan of thousands had set out from Honduras last week in hopes Mexico would grant them passage, posing a fresh test for President Donald Trump’s effort to reduce the flow of migrants arriving at the U.S. border by pressuring other governments to stop them.

READ MORE: Migrants cross river into Mexico after being refused passage to U.S.

Mexican Foreign Secretary Marcelo Ebrard said 2,400 of the migrants entered Mexico legally over the weekend. About 1,000 of them requested Mexico’s help in returning to their countries. The rest were being held in immigration centers while they start legal processes that would allow them to seek refuge in Mexico or obtain temporary work permits that would confine them to southern Mexico.

An additional 1,000 had tried to enter illegally Monday, he said, and hundreds of them were apparently detained by Mexican National Guardsmen and immigration agents. Immigration officials estimated Monday night that 500 had evaded capture by the security forces.

Ebrard said Mexico already has begun deporting some back to Honduras, putting 110 on a flight to San Pedro Sula and sending 144 back by bus.

Honduran Deputy Foreign Minister Nelly Jerez said Mexico expected to deport 500 Hondurans a day on buses from Wednesday through Friday.

Most of the hundreds stranded in the no-man’s land on the Mexican side of the river returned to Guatemala overnight in search of water, food and a place to sleep. Mexican authorities distributed no water or food to those who entered illegally, in what appeared to be an attempt by the government to wear out the migrants.

Alejandro Rendón, head of Mexico’s federal social welfare department, said his colleagues were distributing water to those who turned themselves in or who were caught by immigration agents, but were not doing the same along the river because it was not safe for workers to do so.

“It isn’t prudent to come here because we can’t put the safety of the colleagues at risk,” he said.

Mexico President Andrés Manuel López Obrador said Tuesday that the government is trying to protect the migrants from harm by preventing them from traveling illegally through the country. He said they need to respect Mexican laws.

“If we don’t take care of them, if we don’t know who they are, if we don’t have a register, they pass and get to the north, and the criminal gangs grab them and assault them, because that’s how it was before,” he said. “They disappeared them.”

On the Guatemala side Tuesday, migrants lined up at a shelter for a breakfast of plantains, beans and coffee. Some asked for dry clothing to replace what was soaked or lost in their dash into Mexico. Others passed the time playing soccer and cards beside the river as they tried to figure out what to do next.

Darlin René Romero, 25, and his wife were among the few who spent the night pinned between the river and Mexican authorities.

Rumors had circulated through the night that “anything could happen, that being there was very dangerous,” Romero said. But the couple from Copan, Honduras, spread a blanket on the ground and passed the night 20 yards from a line of National Guard troops forming a wall with their riot shields.

They remained confident that Mexico would allow them to pass through and were trying to make it to the northern Mexican city of Monterrey, where his sister lives.

They said a return home to impoverished and gang-plagued Honduras, where most of the migrants are from, was unthinkable.

“We are in no-man’s land,” said Alan Mejía, whose 2-year-old son was cradled in his arms clad only in a diaper as his wife, Ingrid Vanesa Portillo, and their other son, 12, gazed at the riverbank Monday night. Mejía joined in five previous migrant caravans but never made it farther than the Mexican border city of Tijuana.

“They are planning how to clear us out, and here we are without water or food,” said a desperate Portillo. “There is no more hope for going forward.”

Sonia Pérez D. reported from Tecun Uman, Guatemala.