Mr. Trump is not just historically unpopular; he is also central to voter perceptions of the Republican Party — a lesson Republicans ruefully learned in the electoral wipeouts they suffered in Virginia and New Jersey last November.
An NBC News-Wall Street Journal poll released Friday found that 38 percent of voters said they wanted to send a message of opposition to Mr. Trump with their midterm vote, the highest figure making such a statement since Democrats reclaimed both chambers of Congress in 2006.
The shutdown of 2013 and another in 1995 featured a deft Democratic politician in the White House who skillfully directed voter anger to the Republicans in Congress. President Bill Clinton was able to blame Newt Gingrich, the House speaker at the time, even after he vetoed spending bills that would have kept the government open.
This time around, Democrats in Congress are confident that they can rely on Mr. Trump’s inevitable outbursts to motivate their base and win over moderates. That confidence has emboldened Democrats to engage in some brinkmanship that they may have steered away from with a less bombastic figure in the White House.
“The president is going to figure in almost every voter’s mind in the midterms,” said Senator Brian Schatz, Democrat of Hawaii, adding: “Democrats have learned that it’s not in our interest and it’s not consistent with our values to constantly get rolled.”
Nor is it so politically daring when they are facing an opposition that spent much of Thursday deploying an alliterative hashtag, #schumershutdown, to try to pin the blame for a shutdown on Senator Chuck Schumer, the Democratic leader, only to see Mr. Trump summon the would-be boogeyman to a White House meeting on Friday without any Republican lawmakers present.
Congressional Republicans could only chuckle about the uncertain staying power of their newly hatched slogan.
“I’m not sure what the recycling life on a hashtag is,” said Representative K. Michael Conaway, Republican of Texas.
Mr. Trump did not wind up devising an agreement of his own with Mr. Schumer during their 90-minute one-on-one in the West Wing. But the president’s unilateral decision to enter into his own negotiation was a reminder to Republicans that their president is effectively a political free agent who acts more on whim, and with an eye toward media coverage, than any fixed worldview.
Asked if he was alarmed about Mr. Trump’s meeting with Mr. Schumer alone, Senator Roy Blunt of Missouri was succinct: “Yes.”
This is not to say that Senate Democrats, particularly those running this fall in the heavily white states that Mr. Trump swept in 2016, do not face any risk in a shutdown, especially if it is seen as revolving largely around protecting the young undocumented immigrants known as Dreamers.
Polling done by a Democratic “super PAC,” the Senate Majority PAC, revealed that in Indiana, Missouri, Montana, North Dakota and West Virginia, voters would fault Democrats if DACA, the program shielding the young immigrants from deportation, is what prompted the crisis.
Senate Democrats are up for re-election in each of the five states, and if the party does not hold nearly all of the seats, it has no chance to net the two seats necessary to claim the majority.
“They’ve kind of gotten out over their skis,” Senator John Cornyn of Texas, the second-ranking Republican, said of Democrats. “Everybody realizes this is all about immigration.”
And Republicans were heartened by a CNN survey released Friday showing that far more Americans believe it is more important to avoid a government shutdown than continue DACA.
Yet every poll indicates that voters would blame Republicans if Congress does not keep the government open, and veteran party officials concede that they would face a communications challenge in making the case that they were not responsible for a shutdown.
“The general numbers will work in the Democrats’ favor because the country will hold Republicans a little more responsible because they control the entire government,” Mr. Gingrich said.
He argued that the red-state Senate Democrats were “playing with nitroglycerin,” and as evening fell on Friday, three of them made clear that they would support a measure to keep the government open: Mr. Manchin, Senator Joe Donnelly of Indiana and Senator Heidi Heitkamp of North Dakota.
But the former speaker, who has been one of Mr. Trump’s stoutest defenders, conceded that the president’s intervention with Mr. Schumer also complicated the issue for Republicans. And few know more than Mr. Gingrich about how difficult it is to remain steadfast on a shutdown strategy when party unity breaks down.
If Mr. Trump and Senate leaders hammer out an agreement that offers legal status to the Dreamers but is not perceived as sufficiently tough on other immigration and border security measures, it may cause heartburn among conservative lawmakers.
“If you’re in the House rank and file, you get very nervous,” Mr. Gingrich said. “You begin to think: ‘Do I have to vote against this?’”
House Democrats, shut out of power in Congress but handed the political gift of Mr. Trump’s unpopularity and unpredictability, could only look on in delight.
“He’s as frustrating to his own party, quite frankly,” said Representative Joseph Crowley of New York.