The US house of representatives has voted to reopen the federal government and pass a 400 billion dollar (£287 billion) budget deal, overcoming opposition from both liberal Democrats and tea party conservatives to endorse enormous spending increases despite looming trillion-dollar deficits.
The 240-186 vote came in the pre-dawn hours, putting to bed a five-and-a-half hour federal freeze - the second such shutdown in three weeks.
The breakdown came largely in the senate, the upper chamber of congress, when Republican senator Rand Paul of Kentucky went rogue and stalled a vote in protest over his party's willingness to approve spending increases.
Democrats also experienced divisions, largely on account of liberals upset the measure was not tied to any plans to assist the "Dreamer" immigrants, brought into the country illegally as children.
Most Democrats opposed the measure, following the lead of minority leader Nancy Pelosi, who tried and failed to use the moment to secure a promise for a separate vote on immigration. Up to the final minutes, it was not clear the bill would pass and many Democrats held their votes, allowing the tally to creep slowly and giving no indication which way it might fall.
House speaker Paul Ryan urged congress to avoid a "second needless shutdown in a matter of weeks - entirely needless".
There was far less drama in the senate, where the measure sailed through by 71-28. US president Donald Trump has promised to sign the bill into law.
The White House was forced to order the government shutdown shortly after midnight, but leaders moved quickly before federal employees were due back at work, hoping to minimise the disruption. A shutdown essentially cuts the federal workforce in half, with those dubbed non-essential not allowed to work, while military and essential workers remain on the job.
The House vote ensured most employees would report for work as usual. Under federal law, passage of the measure is enough to call off the shutdown; Mr Trump is expected to sign the measure as soon as he receives it.
The White House kept its distance from the quarrelling on Capitol Hill - Mr Trump did not tweet on the matter, and advisers did not try to assign blame.
Senate Republicans, however, were clearly irked by the debacle. In his attempt to sway Rand Paul to relent, senator John Cornyn of Texas declared his fellow Republican was "wasting everyone's time" and prompting a shutdown for "no good reason". But Mr Paul, the resident contrarian, repelled suggestions to stand aside.
"I didn't come up here to be part of somebody's club," Mr Paul said. "I didn't come up here to be liked."
The bill includes huge spending increases sought by Republicans for the Pentagon along with a big boost demanded by Democrats for domestic agencies. Both sides pressed for 89 billion dollars (£63 billion) for disaster relief, extending a host of healthcare provisions, and extending a slew of smaller tax breaks.
It also would increase the government's debt cap, preventing a first-ever default on US obligations.
Why are you making commenting on The Herald only available to subscribers?
It should have been a safe space for informed debate, somewhere for readers to discuss issues around the biggest stories of the day, but all too often the below the line comments on most websites have become bogged down by off-topic discussions and abuse.
heraldscotland.com is tackling this problem by allowing only subscribers to comment.
We are doing this to improve the experience for our loyal readers and we believe it will reduce the ability of trolls and troublemakers, who occasionally find their way onto our site, to abuse our journalists and readers. We also hope it will help the comments section fulfil its promise as a part of Scotland's conversation with itself.
We are lucky at The Herald. We are read by an informed, educated readership who can add their knowledge and insights to our stories.
That is invaluable.
We are making the subscriber-only change to support our valued readers, who tell us they don't want the site cluttered up with irrelevant comments, untruths and abuse.
In the past, the journalist’s job was to collect and distribute information to the audience. Technology means that readers can shape a discussion. We look forward to hearing from you on heraldscotland.com
Comments & Moderation
Readers’ comments: You are personally liable for the content of any comments you upload to this website, so please act responsibly. We do not pre-moderate or monitor readers’ comments appearing on our websites, but we do post-moderate in response to complaints we receive or otherwise when a potential problem comes to our attention. You can make a complaint by using the ‘report this post’ link . We may then apply our discretion under the user terms to amend or delete comments.
Post moderation is undertaken full-time 9am-6pm on weekdays, and on a part-time basis outwith those hours.
Read the rules here