The US government has avoided a federal shutdown after both House and Senate agreed on a short-term funding deal.
A bill that keeps the government funded until mid-November but includes no new aid for Ukraine was approved in the Senate by 88 votes to nine.
The 45-day resolution was proposed by House Speaker Kevin McCarthy after a rebellion by hard-line fellow Republicans who control the chamber.
Once signed into law, it will avert a disruption of federal services.
A shutdown, which would place tens of thousands of federal employees on furlough without pay and suspend various government services, was slated to begin at 00:01 ET (04:01 GMT) on Sunday.
But in a dramatic turnaround on Saturday afternoon, House Republicans scrambled to pass a temporary funding measure that would keep the government open for 45 more days and make no major concessions on spending levels.
It was backed by more Democrats than Republicans, with as many as 90 Republicans voting against it.
The move was a blow to a small group of right-wing Republicans who have held up negotiations in the chamber with unyielding demands for spending cuts.
However, with a majority of lawmakers keen to avert a shutdown, one of the faction’s key demands – no more US funding for Ukraine’s defence against its invasion by Russia – is reflected in the bill.
In a statement released shortly after the Senate vote, President Joe Biden said “extreme House Republicans” had sought to create a “manufactured crisis”, and urged Speaker McCarthy to allow a further funding deal for Ukraine to pass without delay.
He said: “We cannot under any circumstances allow American support for Ukraine to be interrupted.
“I fully expect the Speaker will keep his commitment to the people of Ukraine and secure passage of the support needed to help Ukraine at this critical moment.”
Speaking after the deal passed, Democratic Senate majority leader Chuck Schumer said “Americans can breathe a sigh of relief” and that “extreme, nasty and harmful” budget cuts some Republicans had pushed for had been avoided.
But he stressed the agreement was temporary and not the “final destination”, assuring Kyiv that a further funding package for Ukraine had not been abandoned.
Mr Schumer said there was majority support in both parties to continue financial assistance for its military, adding: “We will not stop fighting for more support for Ukraine.”
In an unusual move, senior Senate leaders from both parties, including minority leader Mitch McConnell, released a joint statement signalling their intention to “ensure the US government continues to provide” support to Ukraine in the coming weeks.
It came after Senator Michael Bennet – a Democratic member from Colorado, who backs more funding for Kyiv – held up Saturday’s proceedings in protest at the lack of guarantees for Ukraine included in the deal.
Shutdowns happen when both chambers of Congress are unable to agree on the roughly 30% of federal spending they must approve before the start of each fiscal year on 1 October.
What happens in a US government shutdown?
With Republicans holding a slim majority in the House and Democrats holding the Senate by a single seat, any funding measure needs buy-in from both parties.
Repeated efforts to pass spending bills in the House have been thwarted in recent weeks by rebel right-wingers.
The group has opposed short-term spending measures and pushed for making cuts by passing long-term spending bills with agency-specific savings, even though such bills stand little chance of advancing through the Senate.
Speaker Kevin McCarthy had been extremely reluctant to rely on Democratic votes to pass the House’s bill until the last minute, given this would anger these hard-line conservative members of his party.
But Democrats did not get everything they wanted. In order to avoid a shutdown, they had to abandon their hopes of providing further military aid to Ukraine.
They – and Republicans who also support more Ukraine money – will keep pressing for more funding, but officials in President Joe Biden’s administration have warned that, in the short term, there could be disruption to the Ukrainian war effort.
“We fully expect Speaker McCarthy, who has stated his support for funding to support Ukraine in its fight against Russia’s illegal and unjustified war of aggression, will bring a separate bill to the floor shortly,” a White House official told the BBC’s US partner CBS News.
This drama is likely to be repeated again in 45 days, as fundamental disagreements over government spending levels and policies between Republicans and Democrats, and among Republicans themselves, have not been resolved.
In the meantime, Florida Congressman Matt Gaetz and hard-line conservatives in the House have a decision to make.
Mr McCarthy’s decision to rely on Democratic votes to pass the short-term bill was supposedly a red line that, if crossed, would prompt a right-wing rebellion in the House and an attempt to remove Mr McCarthy from his leadership position, by triggering a so-called motion to vacate.
At his Saturday news conference, Mr McCarthy challenged those who oppose him. “If somebody wants to bring a motion against me, bring it,” he said. “There has to be an adult in the room.”
The days ahead will reveal whether Mr Gaetz and company were serious about their threat – or just bluffing.