Washington - The US government reopened its doors on Thursday after Congress passed legislation to end a government shutdown and - just in the nick of time - avert a US debt default in 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 passed it late Wednesday night 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 on Thursday.
Congress had faced a deadline of 23:59 on Thursday to raise the government's borrowing authority or risk a default on its obligations.
The bill reopens the government through to 15 January and permits the Treasury to borrow normally through to 7 February or perhaps a month longer. It includes nothing for Republicans demanding to eradicate or scale back Obama's signature health care overhaul.
"We fought the good fight. We just didn't win," conceded House Speaker John Boehner as lawmakers lined up to vote on the bill.
At the White House, 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 1 October with a partial shutdown of the federal government after House Republicans refused to accept a temporary funding measure unless 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. Obama vowed repeatedly not to pay a "ransom" in order to get Congress to pass normally routine legislation.
The hard-right tea party faction of House Republicans, urged on by conservative Senator Ted Cruz of Texas, had seen both deadlines as weapons that could be used to gut Obama's Affordable Care Act, designed to provide tens of millions of uninsured Americans with coverage.
The Democrats remained united against any Republican threat to Obama's signature programme, and Republicans in the House could not muster enough votes to pass their own plan to end the impasse.
More than two million federal workers - those who had remained on the job and those who had been furloughed - would be paid under the agreement.
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," Boehner said in a statement.
Return to work
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," 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 standoff 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".
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 imperiling the House leadership, but Boehner was ready to end the crisis that had badly damaged Republican approval among voters.
Looking forward, lawmakers 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 standoff.
"This package is just a joke compared to what we could have gotten if we had a more reasonable approach," he said.