The US has narrowly avoided a government shutdown – with just three hours to spare before current funding expired.
A rushed package means agencies will be able to continue operating as normal for the next 45 days, ending days of turmoil in Washington.
However, this temporary solution has dropped aid to Ukraine – an issue that will need to be revisited with a growing number of Republican lawmakers.
Had a deal not been reached, four million government employees would have been left unpaid – with national parks and financial regulators forced to shut their doors.
Active-duty soldiers would have had to work without pay, and nutrition aid to seven million poor mothers suspended.
There could also have been knock-on effects with airport security and border control, delaying passengers.
Democratic Senate majority leader Chuck Schumer said: “The American people can breathe a sigh of relief – there will be no government shutdown … today, MAGA extremism has failed and bipartisanship has prevailed.”
A shutdown had looked all but inevitable earlier in the week, with right-wing politicians calling for government agencies to slash their budgets by up to 30% – a move that the White House and the Democrats rejected as too extreme.
That plan collapsed on Friday, with Republican House Speaker Kevin McCarthy abandoning those demands.
He instead relied on Democrats to pass the bill – putting his own job at risk – paving the way for the Senate to pass the measure 88-9.
Mr McCarthy later struck a defiant tone and dismissed concerns he could be ousted as leader, telling reporters: “I want to be the adult in the room, go ahead and try.
“And you know what? If I have to risk my job for standing up for the American public, I will do that.”
President Joe Biden has welcomed the deal, and says it prevents “an unnecessary crisis that would have inflicted needless pain on millions of hard-working Americans”.
He added: “I want to be clear – we should never have been in this position in the first place. Just a few months ago, Speaker McCarthy and I reached a budget agreement to avoid precisely this type of manufactured crisis.
“For weeks, extreme House Republicans tried to walk away from that deal by demanding drastic cuts that would have been devastating for millions of Americans. They failed.”
Mr Biden went on to warn that US support for Ukraine cannot be interrupted when the country is at a “critical moment”.
Analysis: A sticking plaster, but lots unresolved
It was brinkmanship, about as close to the brink as it gets.
US networks had been running “countdown clocks” to government shutdown and they showed less than nine hours when the breakthrough vote happened in the House.
It was the magic key to avoiding a shutdown and everything that would have entailed – the closures, the workers unpaid, the multibillion-dollar hit to the economy and the rest.
It came down to last-minute political gymnastics. Kevin McCarthy, Republican Speaker of the House of Representatives, had spent weeks trying, and failing, to corral right-wing members of his party behind a preferred funding plan.
Their objections stood in his way and they didn’t budge. It was a measure of the influence wielded by the likes of Matt Gaetz and Marjorie Taylor-Greene, once on the faraway fringe, but now key players in the party.
At the last-minute, McCarthy’s 45-day stopgap proposal to avoid a shutdown was carried forward only when Democrats weighed in behind it.
It may yet come back to bite Mr McCarthy, one of America’s most prominent political figures.
His right-wing party critics had threatened to oust him if he counted on Democrat votes.
It’s one loose end among many – not least the issue of funding for Ukraine.
The bill that has averted the shutdown doesn’t include $6bn (£4.9bn) in Ukrainian aid – a concession demanded by many Republicans in the House of Representatives.
How that squares with a US government commitment to aiding the war effort will be central to the discussions in the 45 days that this bill buys.
Democrats who nodded it through saw the danger in being seen to deprioritise US domestic interests amidst the immediate threat of a shutdown.
Having pulled back from the brink, they will wrestle with the danger they see in deprioritising Ukraine and its war effort.