Branding the move a “political stunt”, the former president mocked the suggestion “the biggest threat to America — the biggest threat! — is some impoverished refugees a thousand miles away”.

Without mentioning him by name, Mr Obama repeatedly criticised Mr Trump’s habit of making false claims - “I believe in fact-based campaigns,” he noted - and of stoking racial and religious tensions.

"We have seen repeated attempts to divide us with rhetoric designed to make us angry and make us fearful," Mr Obama said to a 3,000-strong audience of mostly Democrat supporters in Miami, Florida, on Friday night.

“It’s designed to exploit our history of racial and ethnic and religious division that pits us against one an another – to make us believe that somehow order will be restored if it weren’t just for those folks who don’t look like we look.”

Barack Obama: 'we have seen repeated attempts to divide us with rhetoric designed to make us angry and make us fearful'

Speaking ahead of the midterms next week, Mr Obama added: "But in four days, Florida, you can be a check on that kind of behaviour."

Mr Obama was flanked by gubernatorial candidate Andrew Gillum, who faces former congressman and strong Trump backer Ron DeSantis, and senator Bill Nelson, who is being challenged by the outgoing governor, Rick Scott, in Tuesday's elections.

US midterm elections: the voters Show all 10 1 /10 US midterm elections: the voters US midterm elections: the voters Ross Kershey of Exton, Pennsylvania objects to President Trump's recent threat to unilaterally suspend the constitutional protection of birthright citizenship as a way to control undocumented immigrants AP US midterm elections: the voters Thomas Jakel of Eveleth Minnesota is a former miner. The economy is the most important thing to voters in his town AFP/Getty US midterm elections: the voters Jerry Mcneff of Exton, Pennsylvania intends to split his ballot between the parties for Pennsylvania's House, Senate and governor elections AP US midterm elections: the voters Jean Hoffman of Exton, Pennsylvania has concerns about the cost of her daughters' college education. She thinks that voting Republican might help extend the economy's rise AP US midterm elections: the voters Supporters attend a rally of President Trump in Rochester, Minnesota AFP/Getty US midterm elections: the voters Supporters attend a rally of President Trump in Rochester, Minnesota Reuters US midterm elections: the voters Supporter Jenny Haley and son wait in line to see a Trump Rally in Rochester, Minnesota AFP/Getty US midterm elections: the voters Dick Calef of Exton, Pennsylvania is a life-long Republican. He credits the economic gains in suburban Philadelphia to longer-term factors beyond Trump's policies, such as the growth of internet and health care companies. He's not yet sure how he will vote AP US midterm elections: the voters Markus Fasel of Mendota Heights, Minnesota attends a campaign event for Democrat Angie Craig, his favoured congressional candidate AFP/Getty US midterm elections: the voters Supporters attend a rally of President Trump in Rochester, Minnesota Reuters

On Mr Trump’s pledge to end birthright citizenship, Mr Obama said: “I’m assuming that they recognise that a president doesn’t get to decide on his who’s an American citizen and who’s not. That’s not how the Constitution of the United States works. That’s not how the Bill of Rights works. That’s not how our democracy works.”

The midterm elections, Mr Obama said, are a ballot on the “character of our country”.

The former president was repeatedly interrupted by hecklers, prompting him to quip: "Why is it that the folks who won the last election are so mad all the time?"

At his own rally in West Virginia, Mr Trump quickly fired back at his White House predecessor.

“I heard President Obama speak today. I had to listen, I was in the plane. I had nothing else to do," Mr Trump said in West Virginia.

Support free-thinking journalism and attend Independent events

Responding to accusations by Mr Obama he was lying about healthcare pledges, Mr Trump hit back, claiming the former president did not keep his promises to voters.

The president said Mr Obama's assertion that "if you like your doctor, you can keep your doctor" under the Affordable Care Act proved false. Some Americans were forced to change providers or health plans under the law.