The federal government technically shut down at 12:01 am Eastern time Friday for the second time in three weeks.

Congressional leaders had struck a deal that would fund the government through March 23 and set up a two-year budget agreement. But Sen. Rand Paul (R-KY) filibustered the agreement to prevent the Senate from voting on the new proposal before a midnight deadline, angry over the plan to add hundreds of billions of dollars in federal spending in the next few years.

The Senate did vote, eventually, though, and the spending plan passed with 71 votes a little before 2 am Friday. It was onto the House, where a revolt from archconservatives meant Republican leaders needed Democratic votes to keep the government open — and it’s not clear that they would get them.

Democratic leaders wanted assurances that the House will advance legislation addressing the Deferred Action for Childhood Arrivals program that would give deportation protections to unauthorized immigrants brought to the United States as children. That’s the same immigration issue the government shut down over last time. House Minority Leader Nancy Pelosi had dug in against the budget deal without an immigration agreement, speaking on the House floor for hours on Wednesday in a passionate plea to resolve the issue.

But the lower chamber cobbled together the votes, and the bill passed 240 to 186: 167 Republicans and 73 Democrats voted to reopen the government at about 5:30 am, ending the second government shutdown of 2018.

Rand Paul had a big problem with the new massive budget deal

To pass a bill before the government shuts down at midnight, Senate leaders needed the agreement of every senator to hold a vote. But Paul withheld his consent, angling for a vote on his amendment that would instead preserve the so-called sequestration budget caps. He took to the Senate floor a little before 6 pm to rail against the budget deal.

Vox’s Tara Golshan ran through the particulars of the spending deal that Senate leaders announced earlier this week. It would fund the government through March 23, in order to give congressional staff the time to write bigger appropriations bills that would actually fund the federal government for the next two years, under the parameters laid out in the budget deal that Congress is about to pass at the same time.

As Golshan explained:

On Wednesday, Senate Majority Leader Mitch McConnell and Minority Leader Chuck Schumer announced a deal on budget caps that would increase investments in domestic programs and the military by roughly $300 billion over the next two years: The deal lifts funding for domestic programs by $128 billion and hikes defense budgets by $160 billion. ... This agreement is the result of a fight that goes back to 2011 when an Obama-era impasse over the debt ceiling brought the American economy to near calamity, which ultimately resulted in the 2013 sequester, setting into law across-the-board budget cuts and establishing budget caps that would amount to $1.2 trillion in cuts over the next 10 years.

This is what Paul, one of the Senate’s foremost budget hawks, opposes. He believes the spending caps should be kept because federal spending is already too high.

“It spends too much money, borrows too much money. Actually, we’re going to bring back Obama-era deficits. I was elected to combat Obama-era deficits,” the Kentucky senator said on Fox News Thursday evening. “Someone has to stand up and say, ‘You should spend what comes in. We should balance our ledger.’ That used to be what it meant to be conservative.”

JUST NOW: @RandPaul says he told Trump today to call @SenateMajLdr, to tell him Paul wanted 15 min to debate, 15 min to vote, "We could have been done by noon." Adds: "If they want to stay up til 3 in the morning, I’m happy to do it for something I consider to be important." pic.twitter.com/GkK6m9G2bD — Pat Ward (@WardDPatrick) February 8, 2018

But he was one of the few who feel that way, and under the Senate rules, the chamber could start voting at 1 am, with or without him. The short-term spending and long-term budget plan received broad support, more than 70 votes, in the Senate.

But then it headed to the House, where its future was less certain.

House Democrats nearly had their own shutdown over DACA

In the lower chamber, both House Democrats and conservative Republicans had threatened to withhold support for the spending plan.

For conservative Republicans, the budget deal, which McConnell and Schumer announced earlier in the week, was too massive a spending increase. The proposal would increase investments in domestic programs and the military to the tune of $300 billion over the next two years, a major victory for Democrats concerned that a Republican-led government would slash federal programs.

But some Democrats engaged in a high-risk, last-ditch, and ultimate-failed bid to ensure the House actually votes on immigration. With enough conservatives voting against the budget proposal, House Republicans needed Democratic support to keep the government open. Despite supporting the budget deal on its merits, many House Democrats said they needed a promise on a DACA vote as hundreds of thousands young immigrants fear losing protections from deportation and work permits by March 5.

The story changed throughout the day, with different leaders giving different instructions. Around 5 pm, Rep. Luis Gutiérrez (D-IL), a leader on immigration issues, downplayed the shutdown talk. “Sometimes there are whip operations where there are dire consequences for voting no,” he told reporters. “This whip operation is just informational. It’s, ‘How ya feeling?’”

In the end, the defections weren’t enough to sink the spending plan. Though nearly 70 Republicans and 120 Democrats voted against the package, it still passed with 240 votes, about 20 more than it needed.

Meanwhile, the immigration debate still has a long way to go

When Democrats and Republicans voted to reopen the government in late January, after the first shutdown, the idea was they would spend the following weeks cobbling together a deal on immigration and more permanent government spending in the weeks ahead.

But the actual legislative calendar shrank that window for negotiation, and talks have since increasingly splintered. Now Democrats have voted to fund the government again, hoping negotiations will focus on DACA.

In the Senate, Mitch McConnell’s much anticipated — and very mysterious — immigration floor debate is expected to kick off next week. Lawmakers on both sides of the aisle hope the public negotiations will result in a bipartisan bill that addresses the nearly 700,000 undocumented immigrants currently protected from deportation.

But political headwinds in the House are stronger, and remain largely unchanged. For weeks, conservative hardliners have commandeered immigration negotiations. To win enough House Republican votes for the short-term spending bill two weeks ago, House Speaker Paul Ryan promised the Freedom Caucus, the lower chamber’s group of ultraconservatives, that Republican leadership would whip votes for a conservative immigration bill.

Conservatives continue to say there is a path to compromise, but they have shown no willingness to work with Democrats thus far. Ryan has said he will only bring up a bill for a vote if it has President Donald Trump’s blessing, and if it has the support of the majority of the Republican conference — two contingencies that are hard to reconcile with what has to be a bipartisan DACA fix.

Two weeks ago, Trump’s administration briefed Republican congressional aides with an immigration proposal that called for a path to citizenship for 1.8 million undocumented immigrants who came to the country as children, $25 billion to fund a Southern border wall, substantial curtailing of family immigration, and the elimination of the diversity visa lottery program, which would gut the legal immigration system.

The proposal was largely interpreted as a White House alternative to the one bipartisan proposal by Durbin and Sen. Lindsey Graham (R-SC) on immigration that Trump has already shot down.

Both Republican leaders in the House and Senate supported the clarity offered by the White House proposal but made no commitments to the actual policy. By the following week, House Republicans were still discussing the partisan immigration proposal by Rep. Bob Goodlatte (R-VA), which is unlikely to garner any Democratic support. And already some Republicans in the Senate have expressed concern with the proposal’s serious cuts to legal immigration.

Meanwhile, several other groups have also continued negotiations on completely separate tracks:

The shutdown also brought together a larger group of bipartisan negotiators — roughly 30 senators who’ve named themselves the “Common Sense Coalition,” who are intent on moving immigration talks forward but have yet to come forward with a proposal.

The team of Democratic and Republican leadership deputies that have been dubbed the “No. 2s,” consisting of Durbin again, as well as Minority Whip Rep. Steny Hoyer (D-MD), Majority Whip Sen. John Cornyn (R-TX), and Majority Leader Rep. Kevin McCarthy (R-CA), have also been negotiating.

There are two more Democratic-friendly bipartisan proposals in the House and Senate, proposed by Reps. Will Hurd (R-TX) and Pete Aguilar (D-CA) and Sens. John McCain (R-AZ) and Chris Coons (D-DE), both of which propose slimmed-down DACA and border security fixes; both are still in early stages.

In short, the state of immigration negotiations in Congress remains decentralized and disjointed. And Congress will need to vote again next month to fund the government, after the government shut down once over the issue in January and an immigration impasse very nearly prolonged this second shutdown of 2018.