US President Donald Trump has again accused Mexico of failing to curb the flow of migrants illegally entering the US, and threatened to close the border "next week" unless something changes.

Mr Trump's latest tweets ramp up the tension between the neighbours, putting a specific timeframe to his threats to shut the border, one of the busiest in the world.

"If Mexico doesn't immediately stop ALL illegal immigration coming into the United States through our Southern Border, I will be CLOSING the Border, or large sections of the Border, next week," he said.

"This would be so easy for Mexico to do, but they just take our money and 'talk'," he added.

Mexican Foreign Minister Marcelo Ebrard quickly fired back, saying his country "does not act based on threats."

"We are a great neighbour. Just ask the 1.5 million US citizens who have chosen to call our country home, the largest such community outside the United States," Mr Ebrard wrote on Twitter.

Before Mr Trump's latest tweets, Mexican President Andres Manuel Lopez Obrador reiterated that he does not want a "controversy" with the United States, and that Mexico is in fact working to fight illegal immigration.

"All this talk of migrant caravans and such is related to politics and the (US) election campaign -- that's why I'm not going to get into it," he told a press conference.

Mr Lopez Obrador, an anti-establishment leftist who took office in December, has sought to cultivate a cordial relationship with Mr Trump.

And it appeared to be working - until this week, when Mr Trump returned to the Mexico-bashing of his 2016 campaign, as he launches the run-up to his 2020 re-election bid.

Mr Lopez Obrador wants the US to fund $10 billion in economic development programs for Mexico and Central America to attack the poverty and violence he says are the root causes of migration.

The White House appeared to be listening, sending top adviser and presidential son-in-law Jared Kushner to meet with Mr Lopez Obrador in Mexico City last week for talks on the subject.

But Mr Trump himself has returned to campaign form as the 2020 presidential race heats up in America.

On Thursday, he told a crowd at a rally in Michigan that the US would "close the damn border" if Mexico did not do more to stem the flow of migrants crossing illegally into the United States.