I don’t know where Mr. Trump came up with the 27,000 soldiers figure. Perhaps he was referring to the number of National Guard (or Guardia Nacional) troops currently protecting the Mexican border with Guatemala as part of an effort to prevent Central Americans from entering the country en route to the United States. The National Guard was never meant to serve as an immigration agency for the United States. It was created to combat crime in Mexico — something it has failed to do thus far.

But Mexico is not only using the National Guard to turn away Central Americans. It has also agreed to accept immigrants who are seeking asylum in the United States while their applications are being processed. The country is basically America’s waiting room.

The Trump administration has placed great pressure on the Mexican economy to get what officials want, precisely at a time when financial indicators suggest a recession could be looming.

Even so, we are talking about sovereignty, about dignity and basic respect for human rights, under circumstances where the safety of people fleeing gangs, violence and extreme poverty is at stake. Mexico should never forget that for decades it was an “immigrant exporter.” Now it must treat Central Americans with the same care and respect it has always demanded for Mexicans living in the United States.

It’s true: President Trump is using Mexico. And, against all logic, Mexico is letting him get away with it. This has to change.

What can Mexico do? It must refuse to be Mr. Trump’s wall, to be the United States’ waiting room and safety valve. Mexico must re-embrace its honorable tradition of protecting the persecuted and most vulnerable, whether they’re fleeing civil war in Spain or crime and hunger in Central America.

To President López Obrador, I say this: It is a mistake to place bets on Mr. Trump. This is something all his former friends have learned the hard way. Do you really want to be associated with the policies of a president who, according to a recent report in The Times, suggested shooting migrants at the border in the legs? Why haven’t Mexicans taken to the streets in outraged protest?