“I think the country’s worth a debate until 3 in the morning, frankly,” he said.
Senate leaders were left helpless.
“I think it’s irresponsible,” said Senator John Cornyn of Texas, the No. 2 Senate Republican, lamenting what he described as “the act of a single senator who just is trying to make a point but doesn’t really care too much about who he inconveniences.”
Mr. Paul’s ideological opponents were not buying his fiscal rectitude either. Senator Brian Schatz, Democrat of Hawaii, posted on Twitter: “Rand Paul voted for a tax bill that blew a $1.5 trillion hole in the budget. Now he is shutting the government down for three hours because of the debt. The chance to demonstrate fiscal discipline was on the tax vote. Delaying a vote isn’t a profile in courage, it’s a cleanup.”
Before Mr. Paul waged his assault 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, created new 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 leverage 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 issue 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 large 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, giving 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, which was passed to end the last shutdown, expired 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 prepare for a possible lapse in funding, a spokeswoman said Thursday night. Even with a technical lapse in government funding, the effect of the shutdown could be minimal if lawmakers can approve the deal before the workday on Friday.
As the midnight deadline approached, Senate leaders from both parties nudged Mr. Paul to stop holding up the vote. And his colleagues had little to do but wait.
“It’s just further example of the dysfunction of this place,” said Senator Ron Johnson, Republican of Wisconsin. “It’s ridiculous, isn’t it?”
Senator Johnny Isakson, Republican of Georgia, offered a succinct account of his evening: “Living the dream.”
Among the Democratic ranks in the House, the objections were also strenuous, but for reasons very different 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 possible 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 help 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 process.”
Mr. Ryan, for his part, stressed his desire to address the fate of the young immigrants. But he did not offer the kind 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 problem 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 question 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 leverage they have in fiscal negotiations, and the issue 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, the vast majority of 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 simple 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 making 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 important victories in the budget pact, obtaining big increases in funding for domestic programs. Voting against those wins to take a stand on DACA — and, now, possibly prolonging the shutdown — 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 huge 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.”