Updated

Former President Barack Obama derided the deployment of thousands of active-duty troops to the U.S.-Mexico border as a “political stunt” by the Trump administration, as Obama rallied for Florida Democrats and found himself repeatedly heckled by protesters on Friday afternoon.

“They're telling you the existential threat to America is a bunch of poor refugees a thousand miles away,” Obama said of Republicans, referencing the caravan of an estimated 4,000 Central American migrants headed toward the United States.

“They're even taking our brave troops away from their families for a political stunt at the border,” Obama added. “The men and women of our military deserve better than that. So they're just constant fear mongering to distract from the record.”

Earlier this week, Defense Secretary Jim Mattis emphatically denied that the deployment is part of a political stunt ahead of next week's midterm elections. "We don't do stunts in this department. Thank you," Mattis said.

Obama’s comments on the caravan came as he was heckled multiple times during a rally in Miami on Friday afternoon with Democrats ahead of next week’s midterm elections.

At one point, Obama addressed a protester and said, “Sir, don’t curse in front of kids. Come on.”

Obama flew to Miami to campaign for incumbent Democratic Sen. Bill Nelson and Democratic gubernatorial candidate Andrew Gillum. Later Friday, Obama is scheduled to travel to Atlanta to campaign for gubernatorial candidate Stacey Abrams and other Democrats.

“This is what I look forward to -- is having a few hecklers to get me back in the mood,” Obama said after one heckling. “I enjoy that. You always got to have a few in order to know that you're on the campaign trail.”

Interrupted again, Obama told a heckler to attend a Republican rally instead.

“Here's the deal,” Obama said. “If you support the other candidates, then you should go support the other candidates. Don't be here. One of the things I never understood was why if you're supporting the other guy, you come to my rally. Go to their rally.”

The Fox News Senate and Gubernatorial Power Rankings lists both Florida races as “tossup” contests. In the Senate race, Nelson is being challenged by Republican Gov. Rick Scott. Republican Rep. Ron DeSantis is running against Gillum in the governor’s race.

In his remarks, Obama called Gillum “one of the most inspiring, gifted candidates” running this year. He took aim at Republicans, saying “America’s at a crossroads.”

“Maybe most of all, the character of our country is on the ballot,” Obama said. “In the closing weeks of this election we have seen repeated attempts to divide us with rhetoric designed to make us angry and make us fearful. It's designed to exploit our history of racial and ethnic and religious division that pits us against one another.”

Obama also took credit for the improving economy under President Trump.

“Right now, Republicans are all, look, the economy is so good,” he said. “Where do you think that started?”

Obama also referenced the Special Counsel Robert Mueller’s Russia probe, and the indictments of former Trump associates for an assortment of crimes.

“They promised to take on corruption,” Obama said. “Instead, they have racked up enough indictments to field a football team. You know, I didn't have anybody in my administration get indicted.”

Obama’s attempt to energize voters ahead of Tuesday’s vote came on a day of dueling rallies with President Trump.

Trump is campaigning for Republicans Friday in West Virginia, before holding a rally in Indiana.

Fox News’ Samuel Chamberlain contributed to this report.