Senate leaders, experiencing the implacable Senator Rand Paul of Kentucky, deferred the chamber until just after midnight, conceding they could not prevent at least a short-term government shutdown, which will start Friday morning.
Senators are still expected to vote in favor of a far-reaching budget deal in a series of votes that will start around 1 a.m. The House is to follow before daybreak, though the outcome in that chamber is less certain. If the House favors the deal, the government would have reopened before the workday starts.
But Mr. Paul, a Republican, will have made his point. Angered at the big spending increases at the center of the budget deal, the senator delayed passage for hours with a demand to vote on an amendment that would keep in place strict caps on spending that the budget agreement would raise.
“The reason I’m here tonight is to put people on the spot,” Mr. Paul said. “I want people to feel uncomfortable. I want them to have to answer people at home, who said, ‘How appear you were against President Obama’s deficits and then how appear you’re for Republican deficits?’”
He delivered floor speech after floor speech in which he bemoaned what he saw as out-of-control government spending.
“I think the country’s worth a debate until 3 in the morning, frankly,” he said.
Before Mr. Paul waged his offensive on the budget deal, trouble was already brewing in the House, where angry opposition from the Republicans’ most ardent conservative members, coupled with Democratic dissenters dismayed that the deal did nothing for young undocumented immigrants, was creating fresh tension as the clock ticked toward midnight.
Representative Nancy Pelosi of California, the Democratic leader, told a closed-door meeting of House Democrats that she would oppose the deal, and said Democrats would have advantage if they held together to demand a debate on immigration legislation. But she suggested she would not stand in the way of lawmakers who wanted to vote their conscience.
The struggle to push the bill through the House highlighted the divisions within the Democratic caucus over how hard to push on the problem of immigration as Congress prepares to turn its focus to that politically volatile subject.
The text of the deal, stretching more than 600 pages, was released late Wednesday night, revealing provisions big and small that would go far beyond the basic budget numbers. The accord would raise strict spending caps on domestic and military spending in this fiscal year and the next one by about $300 billion in total. It would also lift the federal debt limit until March 2019 and includes almost $90 billion in disaster relief in response to last year’s hurricanes and wildfires.
Critically, it would also keep the government funded for another six weeks, providing lawmakers time to put together a long-term spending bill that would stretch through the rest of the fiscal year, which ends Sept. 30. The previous temporary funding measure was set to expire at midnight on Thursday.
The deal had been expected to sail through the Senate, and the House had planned to vote on it later Thursday, until Mr. Paul took his stand.
The White House Office of Management and Budget instructed federal agencies to arrange for a possible lapse in funding, a spokeswoman said Thursday night. The shutdown would be the second of the year, arriving after a three-day closure last month when the vast majority of Senate Democrats and a handful of Republicans, including Mr. Paul, blocked a bill that would have kept the government open.
This time around, Senate leaders from both parties nudged Mr. Paul to stop holding up the vote.
“It’s his right, of course, to vote against the bill, but I would contend that it’s time to vote,” Senator Mitch McConnell, Republican of Kentucky and the majority leader.
His Democratic counterpart, Senator Chuck Schumer of New York, echoed the sentiment. “We’re in risky territory here,” Mr. Schumer warned.
Among the Democratic ranks in the House, the objections were also strenuous, but for reasons very various from Mr. Paul’s.
With the monthslong budget impasse appearing to be on the cusp of a resolution, lawmakers were girding for a fight over the fate of young immigrants who were brought to the country illegally as children, known as Dreamers, as well as President Trump’s plan to build a wall along the border with Mexico and other probable immigration policy changes.
The uncertain outlook for immigration legislation, and the disagreements on the best strategy to move forward was starkly apparent as Ms. Pelosi commanded the House floor for more than eight hours on Wednesday in an effort to assist the young immigrants. She said she would oppose the budget deal unless Speaker Paul D. Ryan of Wisconsin offered a commitment to hold a vote on legislation in the House that would address the fate of the Dreamers.
On Thursday, Ms. Pelosi herself displayed the conflicting pressures on Democrats. She simultaneously hailed the budget deal while proclaiming she would vote against it. In a letter to colleagues, she explained her opposition to the deal, but also nodded to its virtues and held back from pressuring other Democrats to vote against it.
“I’m pleased with the product,” she told reporters. “I’m not pleased with the procedure.”
Mr. Ryan, for his part, stressed his desire to address the fate of the young immigrants. But he did not offer the type of open-ended commitment that might assuage Ms. Pelosi. Instead, he signaled that whatever bill the House considers would be one that Mr. Trump supports.
“To anyone who doubts my intention to solve this issue and bring up a DACA and immigration reform bill, do not,” he told reporters. “We will bring a solution to the floor, one that the president will sign.”
The fate of the Dreamers has been in quarry since Mr. Trump moved in September to end the Obama-era program that shields them from deportation, known as Deferred Action for Childhood Arrivals, or DACA. The president gave Congress six months to come up with a solution to resolve their fate.
In recent months, Democrats have tried to make use of the advantage they have in fiscal negotiations, and the problem of immigration played a central role in last month’s shutdown. But Democrats have struggled to determine how hard they should push.
In last month’s closure, most Senate Democrats voted to block a bill that would have kept the government open, only to retreat a few days later and agree to end the closure after Mr. McConnell promised a Senate debate on immigration.
This time, House Democrats were clearly split in their calculations about the best way to exert influence over immigration.
Representative Luis V. Gutiérrez, Democrat of Illinois, demanded that Ms. Pelosi use her muscle to “stop the Democrats from folding.”
“Anyone who votes for the Senate budget deal is colluding with this president and this administration to deport Dreamers,” he said. “It is as easy as that.”
Democrats also ran the risk of angering liberal activists who want to see them take a stand. Ben Wikler, the Washington director for MoveOn.org, said House Democrats would be creating a strategic mistake by voting for the budget deal.
“If you’re looking at a boulder and you have a choice between a lever or your bare hands, you should use the lever,” he said.
But Democrats secured essential victories in the budget pact, obtaining big increases in funding for domestic programs. Voting against those wins to take a stand on DACA — and probably shutting down the government — carried its own political risks.
Representative John Yarmuth of Kentucky, the top Democrat on the House Budget Committee, noted that the budget deal “meets nearly every one of our priorities.”
“If Democrats cannot support this kind of compromise, Congress will never function,” he said.
The spotlight was on House Democrats in part because it became apparent that Republican leaders most likely lacked the votes to push the budget deal through the House with only votes from their own party.
A sizable number of House Republicans are rebelling against the deal because of its big increase in spending. The conservative House Freedom Caucus, which has roughly three dozen members, formally opposed the deal.
“It was pretty much a smorgasbord of spending and policy that got added to this,” said Representative Mark Meadows, Republican of North Carolina and the chairman of the Freedom Caucus. “Normally, people who eat at smorgasbords all the time are not the healthiest.”