Updated 06.50
With just hours to go before technically running out of money, US politicians have agreed a deal to avoid the country defaulting on its debt.
Congress has passed legislation allowing America to temporarily keep borrowing money until early February.
The legislation also means hundreds of thousands of federal employees will be allowed to return to work.
President Obama has now signed the legislation into law:
The deal was struck by Senate majority leader Harry Reid and GOP leaders Mitch McConnell, and calls for the Treasury to have authority to continue borrowing through February 7, and reopen the Government through January 15.
It means a fresh round of negotiations ahead of those dates, and Mr Obama said: "Hopefully next time (a deal) won't be in the 11th hour."
The agreement comes just a day before the deadline to raise the Government's $16.7tn (£10.5tn) borrowing limit. Had no deal been reached, the Government would have started to default on its planned payments.
Notably absent from the fresh agreement is a long-held Republican demand to defund aspects of President Obama's signature health care law.
The Senate deal makes only one modest change in the programme that requires individuals and families seeking subsidies to verify their incomes before qualifying.
Republican House speaker John Boehner said: "We fought the good fight, we just didn't win."
He gave a fist pump in front of photographers as he left late talks before the vote.
The agreement sent the stock market soaring on Wednesday, pushing the Standard & Poor's 500 index close to a record high.
Most traders had expected some sort of deal, given that a failure to reach a deal could have pushed the US into another recession.
Eric Wiegland, a senior portfolio manager, said: "Investors have become, unfortunately, accustomed to some of the dysfunction. It's become more the norm than the exception."
And in case there was any doubt, Obama closed with this: