“It’s worrying us,” said Christopher Gascon, chief of the Mexico office for the International Organization for Migration. “How Mexico can handle that is going to be a whole new area of concern. I don’t think the absorptive capacity is there.”

Even before this week, Mexico was facing extraordinary migration pressures. The waves of Central Americans heading north were severely testing Mexico’s border patrol in the south of the country and led to a sharp increase in the number of people applying for asylum in Mexico, with applications more than doubling from 2015 to 2016.

Mexican officials were also scrambling to develop a strategy in case Mr. Trump made good on his promises to increase deportations of undocumented immigrants, a population that includes millions of Mexicans. An intergovernmental group began on Monday to study ways to help integrate deportees into Mexican society.

Beyond that, recent changes in American policy during the Obama administration had already contributed to the surge in Haitian migrants, as well as to a separate wave of Cuban migrants. Thousands of Cubans found themselves stranded in Mexico and Central America this month after the Obama administration ended a longstanding policy that favored Cubans.

Under American pressure, President Enrique Peña Nieto of Mexico had been trying to stanch the flow of migrants heading through his country, starting the Southern Border Program in 2014 in an attempt to control the movement of people and goods crossing the border with Guatemala. The plan contributed to a doubling of deportations between 2013, before it was enacted, and 2016. Nearly all the deportees in recent years have been from Central America.

But the country’s borders remain highly porous. The International Organization for Migration estimates that between 400,000 and 500,000 undocumented migrants transit through the country every year, about 90 percent of them Central Americans.