Donald Trump's threat to shut the U.S. border if Mexico does not halt all illegal immigration has exposed the limitations of the new Mexican government's strategy of trying to appease the U.S. president as he gears up for re-election.

Amid a surge in migrant detentions at the southwest U.S. border, Trump on Friday said he would close the 2,000-mile (3,200-km) frontier, or sections of it, during the coming week if Mexico did not halt the flow of people.

Casting the government under leftist President Andres Manuel Lopez Obrador as the villain in his struggle to curb illegal immigration to the United States, Trump returned to a signature theme of his 2015-2016 presidential election bid.