Democrats are struggling to respond to President Trump and his Republican allies, who are casting the caravan of thousands of migrants headed toward the U.S.-Mexico border as a failure of Democrats to help enact immigration policy in the GOP-controlled Congress.

Some Democrats said Trump is vulnerable to a counterattack on his core campaign issue given that his policies failed to reduce the number of unauthorized immigrants. Yet party leaders and Democratic candidates have largely been silent ahead of the midterm elections, refusing to engage with Trump.

The Democratic and Republican strategies reflect the path each party has charted with two weeks till Nov. 6. Republicans are hoping to retain their Senate majority and limit losses in the House by playing on fears of migrants pouring into the country to rally conservatives, a strategy that helped propel Trump to the presidency in 2016.

Democrats, deeply divided on immigration, are trying to maintain a laserlike focus on health care and the GOP threat to protections for people with preexisting medical conditions, envisioning that as the issue that will determine control of Congress.

On Monday, Trump launched a fresh attempt to deflect blame for the more than 5,000 migrants from Honduras who were making their way north through Mexico. The president and his top aides say the rising number of Central Americans attempting to enter the United States without authorization presents a winning campaign issue, by showing Trump is right to call for stronger border control.

Trump sought to fan public fears on Twitter, suggesting without evidence that the caravan contains gang members and terrorists from the Middle East.

“Every time you see a Caravan, or people illegally coming, or attempting to come, into our Country illegally, think of and blame the Democrats for not giving us the votes to change our pathetic Immigration Laws!” Trump tweeted. “Remember the Midterms!”

Republicans trying to preserve the party’s 51-49 Senate majority said they were thrilled to see Trump lead the charge on immigration, an issue they say could be a powerful motivator in the conservative states dominating this year’s map.

“Democratic opposition to strong immigration security has been a very effective issue for us in Senate races this year,” said Steven Law, head of the Senate Leadership Fund, a conservative super PAC. “I don’t see how the spectacle of a massive horde trying to bust our borders on the brink of a national election remotely helps Democrats.”

Law’s group has recently run ads casting Democratic incumbents in states Trump won as soft on immigration, a tactic GOP candidates have also deployed. Echoing Trump, the Republican in the pivotal Tennessee Senate race issued a statement Monday on the “illegal alien mob” headed to the border.

“It’s not surprising he’s silent as thousands of people try to make their way into our country illegally,” Rep. Marsha Blackburn said of her Democratic opponent, former governor Phil Bredesen. Bredesen spokeswoman Alyssa Hansen accused Blackburn of “disgusting fearmongering” and said he was focused on “common-sense solutions.”

Senate Minority Leader Charles E. Schumer (D-N.Y.) and House Minority Leader Nancy Pelosi (D-Calif.) issued a statement over the weekend saying Trump was “desperate to change the subject from health care to immigration because he knows that health care is the number one issue Americans care about.”

Geoff Garin, a Democratic pollster who has regularly conducted surveys in competitive Senate races, said his party’s candidates ought to stay focused on health care and not let Republicans dictate the terms of the midterm debate in the final weeks.

“If they’re moving to [immigration], it suggests to me that their post-Kavanaugh effort is running out of steam,” he said, referring to the recent polarizing confirmation of Supreme Court Justice Brett M. Kavanaugh.

White House aides have emphasized that they believe Trump’s hard-line immigration message, while potent with his conservative base, also carries significant crossover appeal to independents and some moderate Democrats. They cite polls showing that immigration is among the most important issues for voters in both parties.

One senior official pointed to Democrats who have called for the abolishment of Immigration and Customs Enforcement and who have supported “sanctuary cities” — which do not share information with or use local resources to help some federal immigration enforcement efforts — as being too liberal for the electorate at large.

But some Democratic strategists and former congressional aides said the party was missing a chance to pin the rising border numbers on Trump and hold him accountable for falsehoods he has promoted about the issue.

The president, in his tweets Monday, said the caravan from Honduras was a national emergency, and he told USA Today that he would send troops to the border: “As many as necessary.” He also tweeted that aid would be cut to Honduras, Guatemala and El Salvador, from which a record number of families have traveled to the United States.

However, officials from the Pentagon and State Department said they had received no new directives from the president. Early this year, an immigration plan backed by the White House drew the fewest votes in the Senate of four competing proposals — with just 39 senators voting in favor and 11 Republicans joining Democrats in opposing it.

Leon Fresco, an immigration attorney and former aide to Schumer, said Democrats are concerned that showing too much empathy for the migrants could turn off more conservative voters.

“People who are swing voters are not comfortable with politicians defending people in the caravan. It’s a very difficult, nuanced argument to try to get all those things across,” Fresco said. “But if Democrats switch and say the caravan is a direct result of Trump’s immigration policy, that would shut [Republicans] down completely.”

Yet one Democratic strategist noted Monday that the party does not have a consensus position on immigration enforcement to succinctly counter Trump’s “build a wall” mantra. The strategist pointed to a Pelosi interview last week as an example of the far from potent message: The leader said the party’s immigration platform if it wins the House would focus on providing legal status to younger immigrants, known as “Dreamers,” who entered the country illegally as children.

“How is that responsive to the moment we’re in?” said the strategist, who works on immigration issues and spoke on the condition of anonymity to speak frankly about party strategy. “The notion we shouldn’t be talking about the central issue this president has talked about for three years is crazy.”

The Senate battlefield is a combination of ruby-red states with many rural voters who support Trump and his hard-line immigration platform. But there are also four states up for grabs with sizable Hispanic populations: Nevada, Arizona, Florida and Texas, where Trump campaigned Monday for Sen. Ted Cruz (R).

In those states, Republicans risk alienating moderate and Latino voters by fully embracing Trump’s controversial platform.

“That’s long been pretty much a canard and a fear tactic,” said retiring Sen. Jeff Flake (R-Ariz.), speaking on CNN about Trump’s claim about Middle Easterners in the caravan. The race for Flake’s seat is one of the most competitive Senate contests.

Senate Majority Leader Mitch McConnell (R-Ky.) and his allies have seized on liberal calls to abolish ICE, seeking to link them to Democrats running in red states. This has prompted some Democrats to run ads reassuring voters that they do not endorse that approach.

“I support ICE, funding President Trump’s border wall,” Sen. Joe Donnelly (D-Ind.) said in a recent campaign commercial.

In the House, a reliance on immigration could cut both ways for the GOP. Democrats are favored to win the majority because of anger against the president in moderate, suburban districts.

At the same time, Republicans are trying to prevent a Democratic incursion into more conservative districts, where running on Trump’s immigration agenda could boost their appeal.

Republicans are also trying to retain key districts with large Hispanic populations. One is in New Mexico, across the state’s southern half, where Democrat Xochitl Torres Small criticized the White House’s proposal to send military personnel to the border.

“It is so frustrating for me to see people in Washington try to turn this into a political point and try to polarize people and try to oversimplify something that is complicated and real on the ground here,” Torres Small said Sunday night.

David Weigel in Las Cruces, N.M., contributed to this report.