House Minority Leader Nancy Pelosi, D-Calif., and Senate Minority Leader Charles Schumer, D-N.Y., secured nearly $5 billion in new domestic spending by exploiting disagreements between Trump and GOP lawmakers over spending priorities.
Democrats' lopsided victory on the five-month deal, which is likely to be approved this week, means it will be very difficult - if not impossible - for the GOP to exert its will in future budget negotiations, including when it comes to Trump's 2018 budget blueprint.
That's because Republicans are hopelessly divided over how much to spend on government programs, with a small but vocal minority unwilling to support such measures at all. That has forced Republicans to work with Democrats to avoid politically damaging government shutdowns.
And that means Democrats are in the driver's seat when it comes to budget battles, even with Trump in the White House.
"I think we had a strategy and it worked," Schumer said in an interview with The Washington Post. "Democrats and Republicans in the House and Senate were closer to one another than Republicans were to Donald Trump."
The extra money for domestic programs will now be that much harder to strip out of future budgets, and Trump's priorities, such as money for a wall along the border with Mexico, could be more difficult to include.
"We can't pass anything without them," Sen. John Cornyn, R-Texas, a top deputy to Senate Majority Leader Mitch McConnell, R-Ky., said of Democrats recently.
Hill Republicans remain skeptical of, if not openly hostile to, many of Trump's plans - including the wall and proposals to slash millions from programs such as the National Institutes of Health and foreign aid.
In addition to the $5 billion in domestic spending, the bipartisan agreement released early Monday morning is packed with Democratic priorities, such as protection for funding for Planned Parenthood, a permanent extension of health care for coal miners and money to help Puerto Rico make up a projected shortfall in Medicaid.
Pelosi celebrated in a letter to House Democrats on Monday, saying that the measure "reflects significant progress defeating dangerous Republican riders and securing key victories for Democratic priorities."
"In a defeat for President Trump, the [deal] does not fund the immoral and unwise border wall or create a cruel new deportation force," Pelosi wrote.
Democrats are counting on GOP infighting over spending to guarantee that those parts of Trump's agenda won't be funded in the next spending deal, either.
Republicans could try to craft a new agreement to govern spending after Sept. 30, complete with domestic cuts and funding for Trump's wall. But such a measure would probably fail in the Senate, where Republicans hold a slim 52 to 48 majority, short of the 60 votes needed to pass most legislation.
Or, as they have often done in the past, lawmakers could abandon broad ambitions and decide to simply extend current spending levels, locking in Democrats' policy victories for another year.
Republicans in Congress were unusually quiet about the deal. But White House aides sought to put a positive spin on areas where Trump fell short, including the wall.
"I think it's great that the Democrats like the bill," White House budget director Mick Mulvaney told reporters during a Monday briefing. "We thought it was a really good deal for this administration as well."
He said the White House agreed not to "push for bricks and mortar for the wall" but to instead focus on fixing existing fencing and installing new lights and sensors on the border. Mulvaney was one of several top Trump aides who insisted that plans for wall construction would soon begin anew.
"Make no mistake, the wall is going to be built," White House press secretary Sean Spicer said at his daily briefing, adding that there is plenty the administration can do to plan for construction between now and when Trump gets his next opportunity to secure funding.
But wall construction was one of several areas where GOP lawmakers' decision to punt this week could doom the president's priorities for the future.
Language in the deal explicitly prohibits money for border security from being used for building the wall, for instance. Trump has said he plans to revive the push this fall.
Both Spicer and Vice President Mike Pence said they considered the $21 billion in additional military spending - $15 billion from an off-budget war fund and $6 billion in budget increases - to be their biggest victory, even though it was about two-thirds of what Trump had sought.
Additionally, there were no reductions in funding to "sanctuary cities"; a federal judge said last week that the Justice Department needed congressional approval to follow through on its threats to cut money for such places, which don't comply with federal immigration authorities. Nor was there money to fulfill Trump's promise of a hiring spree to build a deportation force at Immigration and Customs Enforcement.
Trump also agreed to continue paying Affordable Care Act subsidies after his aides threatened last week to use that issue as a bargaining chip. The subsidies, which go to insurance companies, reduce out-of-pocket expenses for low-income people who get coverage under President Barack Obama's signature domestic initiative.
Pence celebrated the deal Monday, saying Trump himself played a key role in reaching it.
"I think this morning's announcement about reaching a bipartisan deal on the budget says that the American people can be encouraged that Washington is working again, thanks to the strong leadership of President Donald Trump," Pence said on "CBS This Morning." "Thanks to his direct engagement with members of Congress, we're seeing real progress."
But Trump's involvement was seen by many congressional aides as unhelpful to reaching a deal in the bipartisan talks. Negotiators were nearing an agreement on the spending portions and were ready to move on to unrelated policy measures when Mulvaney publicly renewed demands that the bill include money for a wall along the southern border.
Mulvaney's demand was out of sync with GOP leaders, who long ago said they wouldn't seek any funding for a wall or cuts to sanctuary city funding.
It also came weeks after Schumer personally told Mulvaney that the best way to avoid a government shutdown would be for the White House to stay out of budget negotiations and let Congress work its will, according to two people with direct knowledge of the conversation. Mulvaney nodded, they said, and proceeded to make the demand anyway.
His office did not return a request for comment on the subject.
Democrats also believe that the White House created a public relations crisis when Trump threatened to end payments for the subsidies, which help cover roughly 6 million people under Obamacare. The president later withdrew the threat, and the White House decided to continue the payments, in hopes of reducing the number of sticking points in the spending bill.
But the president put a spotlight on the issue just as public polls were starting to show overwhelming support for the subsidies and the ACA in general. Democrats were thrilled to add the attack on the health-care law to the mix in the spending fight because they thought the public would blame Republicans if a deal couldn't be reached to fund the government, according to several Democratic aides familiar with the strategy.
Now, Democrats believe, the public will also blame the GOP if the subsidies disappear, a win-win for them.
"We had the upper hand, and we maximized that leverage," Schumer said, predicting that the fight would go on. "We figured out our bottom line first, and we made it clear that we had the upper hand because the shutdown would fall on their shoulders."