The fierce backlash underscored the challenge confronting Mr. Schumer and more centrist Democrats as they attempt to negotiate with Republicans and President Trump to reach an agreement on immigration without alienating the more liberal factions of a party that has moved distinctly to the left. Their balancing act reflects the broader tension in the party as it tries to reconcile the fervor of blue-state opponents of Mr. Trump and the caution of Democrats in states where they must appeal to Trump supporters.

Democrats need to protect 10 Senate Democrats up for re-election in states carried by the president and appeal to the swing voters who could flip control of the House. Those vulnerable Senate Democrats were key to sparking the bipartisan drive to bring the shutdown to an end. Yet many of the Senate Democrats considered potential 2020 presidential candidates voted to keep the shutdown going.

Heading into the showdown, Mr. Schumer and other top Democrats figured that Mr. Trump was at a vulnerable moment, given the uproar surrounding racially charged comments made in a recent meeting with senators to discuss immigration, disturbing words that came on top of persistent accounts of Oval Office chaos.

And they saw the so-called Dreamers — the young immigrants brought to the United States illegally as children — as a particularly appealing group, as they faced deportation to countries they barely knew through no wrongdoing of their own. Polling consistently finds deep American sympathy for those immigrants, and under intense pressure from the left to stand tough, Democrats hoped the public would embrace the use of all possible measures to help them.

But over the course of the weekend, Democrats increasingly came to realize they had maneuvered themselves into a difficult position that made many of the party’s moderate senators uncomfortable. Republicans were not distancing themselves from the president despite his erratic swings on immigration policy. And while the Dreamers may be a highly sympathetic group, using them as a rationale for shuttering the federal government was not playing well.