Republicans and Democrats have reached a deal on the US budget, an hour before a deadline that would have forced the government to close many services.
They have passed a stop-gap spending bill which will allow the government to keep running while the wider budget plan is finalised.
The parties have agreed to slash about $38bn (£23bn) from spending for the year until 30 September.
President Barack Obama said the cuts would be difficult but necessary.
"Some of the cuts we agreed to will be painful," he said.
"Programmes people rely on will be cut back. Needed infrastructure projects will be delayed. And I would not have made these cuts in better circumstances."
He said it was the "the biggest annual spending cut in history".
Mr Obama used his weekly radio address on Saturday to reinforce his message, saying that "beginning to live within our means is the only way to protect the investments that will help America compete for new jobs".
The BBC's Mark Mardell in Washington says Mr Obama has put a gloss on the measures, but they are a victory for the Republicans.
Our correspondent says the battles yet to come over the 2012 budget and long-term plans to cut the deficit are likely to be much more difficult.
Announcing the deal, House Speaker John Boehner, a leading Republican, said it had been a "long fight".
"We fought to keep government spending down because it really will create a better situation for job creators," he said.
But in the Saturday Republican radio address, House Budget Committee chairman Paul Ryan said a crisis could be looming.
"Unless we act soon, government spending on health and retirement programmes will crowd out spending on everything else, including national security. It will literally take every cent of every federal tax dollar just to pay for these programmes."
Without an agreement by midnight on Friday, the government would have been forced to shut down, barring some 800,000 government employees from working.
The last US government shutdown came in 1995 amid a dispute between the Republican Congress and Democratic President Bill Clinton's White House.
The shutdown lasted for 20 days and was estimated to have shaved one percentage point off US economic growth for one quarter of the year.
During the current stand-off, talks were stalled for days as Republicans - urged on by the fiscally conservative Tea Party movement - pushed for larger budget cuts than Democrats were willing to concede.