It was only after President Donald Trump threatened to impose tariffs on cross-border trade that the Mexican government reversed course, and from then on the two countries cooperated closely to reduce the flows of third-country migrants across Mexico.