WASHINGTON — In January 2018, Senate Democrats took a politically risky stand, shutting down the government to insist on protections for hundreds of thousands of undocumented immigrants. Gleeful Republicans saw the obstruction strategy as a huge blunder and pounded the Democrats, who caved after only a few days of sharp attacks and cut a deal to reopen.

Times — and circumstances — have changed.

Democrats have now blocked two consecutive coronavirus rescue packages pushed by Republicans and withstood withering criticism to win concessions — and hundreds of billions of dollars — they said were vital. At nearly $500 billion, the latest measure to move through Congress this week ended up being almost twice the size and much broader in scope than the original bill Senator Mitch McConnell, Republican of Kentucky and the majority leader, tried to ram through two weeks earlier without negotiations.

It was a potentially dangerous strategy for Democrats, particularly in an election year, that left them open to accusations from President Trump and congressional Republicans that they were denying desperately needed money at a crucial moment for businesses trying to survive in the face of the pandemic. It may have also reduced their leverage in the next fight over a much larger stimulus measure that is likely to top $1 trillion.

But their willingness to take on those risks reflects Democrats’ confidence that the terrain of the current debate — a public health crisis and economic disaster that will require the broadest government relief effort since the post-World War II era — plays to their core strengths as a party. It is also based in part on their belief that Mr. Trump, whose re-election hopes are likely to rise or fall based on the public perception of his administration’s response to the pandemic, has a strong incentive to compromise with them.