
WASHINGTON — Senate leaders, disregarding President Trump’s blustery threats to shut down the government, neared a far-reaching agreement on Wednesday to set spending levels on military and domestic spending for the next two years, breaking the cycle of fiscal crises that have bedeviled the Capitol since last summer.
The accord was expected to also include disaster relief for areas hit by last year’s hurricanes and wildfires.
Nevertheless, it sparked immediate opposition from the leader of House Democrats, Representative Nancy Pelosi, who said she could not agree to any budget deal that was not accompanied by a promised debate over legislation to protect the fate of young immigrants brought to the country illegally as children, known as Dreamers.
“The budget caps agreement includes many Democratic priorities. With the disaster recovery package and dollar for dollar increases in the defense and nondefense budget, Democrats have secured hundreds of billions of dollars to invest in communities across America. There will be billions in funding to fight opioids, to strengthen our veterans and the N.I.H., to build job-creating rural infrastructure and broadband, and to fund access to child care and quality higher education,” Ms. Pelosi said.
But she added, “This morning, we took a measure of our Caucus because the package does nothing to advance bipartisan legislation to protect Dreamers in the House. Without a commitment from Speaker Ryan comparable to the commitment from Leader McConnell, this package does not have my support.”
She was referring to a promise by Senator Mitch McConnell of Kentucky, the majority leader, to begin debate on immigration soon, a commitment not matched by Speaker Paul D. Ryan.
The budget deal would be paired with a stopgap spending measure that would keep federal agencies open past Thursday, when the current funding measure is set to expire.
Graphic
Can Democrats Win the Senate?
Republicans need to win eight senate races to keep a majority, and Democrats need to win 28 to take it away. Here’s a look at the chances of each outcome.

It was not immediately clear if enough Democrats would oppose the bill to imperil its passage in the House, given the likely opposition from at least some fiscal conservatives. If lawmakers cannot pass a temporary funding measure by the end of Thursday — either by itself or tied to a budget pact — the government would shut down for the second time this year.
The budget agreement would also negate the president’s demands to broadly reorder government with deep cuts to domestic programs like environmental protection, foreign aid, and health care research that were to offset large increases in military spending. Mr. Trump is to release his second budget request on Monday, but the deal — sealed by members of his own party — would effectively render many of his demands null and void.
If the deal passes, lawmakers would put together a long-term spending package over the coming weeks that would fund the government through September, granting a measure of peace to Washington as attention turns to the midterm elections in November. By setting overall spending levels through September 2019, the deal would ease passage of spending bills in the next fiscal year as well.
Only on Tuesday, President Trump was trying to engage in fiscal brinkmanship, threatening another government shutdown if his hard-line demands on immigration were not met.
“I’d love to see a shutdown if we don’t get this stuff taken care of,” Mr. Trump said at a meeting with lawmakers and law enforcement officials to discuss gang violence. “If we have to shut it down because the Democrats don’t want safety,” he added, “then shut it down.”
But budget negotiators seemed to pay him little heed. The budget deal would lift strict caps on military and domestic spending that were imposed in 2011 as part of a deal with President Barack Obama that was once seen as a key triumph for Republicans in Congress. The deal had eluded negotiators for months, as it became intertwined with delicate negotiations on other matters, particularly the contentious issue of immigration.
But after last month’s three-day government shutdown, Senate Democrats agreed to separate spending negotiations from the talks over immigration, border controls and the future of young immigrants brought to the country illegally as children.
The deal also makes for another lonely day for lawmakers concerned about the federal budget deficit, which was already expected to reach $1 trillion in the next fiscal year, according to the Committee for a Responsible Federal Budget, a fiscal watchdog group.
The sweeping tax overhaul approved by Congress in December is projected to add $1.5 trillion to the deficit over a decade, and the budget agreement is expected to allow for hundreds of billions of dollars in additional spending, ballooning the deficit further.