The US government reopened its doors after Congress passed legislation to end a shutdown and – just in the nick of time – avert a debt default.
It came after a bipartisan deal that left Republicans little to show for the epic political drama that threatened to rattle the world economy.
The Senate voted 81-18 to send the measure to the Republican-controlled House of Representatives, which then passed it by 285-144.
President Barack Obama signed the measure – which adhered strictly to the terms he laid down when the twin crises erupted more than three weeks ago – shortly after midnight local time.
Congress had faced a deadline of 11.59pm local time today to raise the government’s borrowing authority or risk a default on its obligations.
The bill reopens the government through to January 15 and permits the Treasury to borrow normally through to February 7 or perhaps a month longer.
It includes nothing for Republicans demanding to eradicate or scale back Mr Obama’s signature health care overhaul.
“We fought the good fight. We just didn’t win,” conceded House Speaker John Boehner as politicians lined up to vote on the bill.
At the White House, Mr Obama hailed the Senate’s vote and promised to sign the legislation immediately.
“We’ll begin reopening our government immediately and we can begin to lift this cloud of uncertainty from our businesses and the American people,” he said.
Less than an hour later, as debate began in the House, Republican Representative Harold Rogers said: “After two long weeks, it is time to end this government shutdown.
“It’s time to take the threat of default off the table. It’s time to restore some sanity to this place.”
The stock market surged earlier on Wednesday at the prospect of an end to the crisis that had threatened to shake confidence in the US economy overseas.
The crisis began on October 1 with a partial shutdown of the federal government after House Republicans refused to accept a temporary funding measure unless Mr Obama agreed to defund or delay his health care law, known as “Obamacare”.
It escalated when House Republicans also refused to move on needed approval for raising the amount of money the Treasury can borrow to pay US bills, raising the spectre of a catastrophic default.
Mr Obama vowed repeatedly not to pay a “ransom” in order to get Congress to pass normally routine legislation.
More than two million federal workers – those who had remained on the job and those who were on unpaid leave – will be paid under the agreement.
Mr Boehner and the rest of the top Republican leadership told their rank and file they would vote for the measure.
But he vowed Republicans were not giving up on the fight to bring down US debt and cripple “Obamacare,” as the president’s signature health care overhaul is known.
“Our drive to stop the train wreck that is the president’s health care law will continue,” he said.
Harry Reid, the Democratic Senate majority leader, thanked Senator Mitch McConnell, the Republican minority leader, for working with him to end what had become one of the nastiest partisan battles in recent Washington history.
“This is a time for reconciliation,” Mr Reid said.
A long line of polls charted a steep decline in public approval for Republicans in the course of what Republican Senator John McCain pronounced a “shameful episode” in US history.
The deal ends the bitter stand-off for now, giving both parties time to cool off and come up with a broader budget plan or risk repeating the damaging cycle again in the new year.
Within moments of the House’s vote, Sylvia Mathews Burwell, director of the Office of Management and Budget, issued a statement saying “employees should expect to return to work in the morning”.
Mr McConnell said the time had come to back away for now from Republican efforts to undermine “Obamacare”. But the feisty minority boss said Republicans had not given up on erasing it from the legislative books.
Passage in the House depended heavily on minority Democrats to support it. The risky move was seen as endangering the House leadership, but Mr Boehner was ready to end the crisis that had badly damaged Republican approval among voters.
Looking forward, politicians were also concerned voters would punish them in next year’s congressional elections. Polls show the public more inclined to blame Republicans.
Republican Senator Lindsey Graham said the party had hurt its cause through the long and dangerous stand-off.
“This package is just a joke compared to what we could have gotten if we had a more reasonable approach,” he said.