President Obama said both sides made tough decisions and given ground on important issues
Related Stories
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”, but said America needed to start living within its means.
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.
John Boehner: ‘It had been a long fight’
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.
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.
This article is from the BBC News website. © British Broadcasting Corporation, The BBC is not responsible for the content of external internet sites.

Leaders Man Utd and Chelsea are among the teams in action on a busy Saturday in the Premier League and there is a full programme in the Football League, after Everton thump Wolves in the day’s early kick-off.
This article is from the BBC News website. © British Broadcasting Corporation, The BBC is not responsible for the content of external internet sites.

The exchange of attacks is the worst violence in the region for two years
Three Hamas militants have been killed in an Israeli air strike on the southern Gaza Strip.
The deaths bring the toll from several days of Israeli strikes to at least 17, including several civilians. Dozens of people have been wounded.
Israel says it is responding to a Hamas missile fired at a school bus, an attack it said had “crossed the line”.
The military wing of Hamas said that attack had been in response to the killing of Hamas leaders last week.
Israel’s strikes and the dozens of rockets and mortars fired by militants across the border represent the worst violence in Gaza in two years.
Israel’s early morning attack on a vehicle in the south of Gaza killed a senior Hamas commander and two of his aides, both Hamas and Palestinian medical workers said.
Hamas named the commander as 29-year-old Tayser Abu Snima, a leader of the militant group in Rafah.
The Israeli military also said it targeted a smuggling tunnel under the Gaza-Egypt border and a lorry carrying ammunition.
The strikes came after overnight rocket attacks on Israel from militants in Gaza that caused no casualties.
Israel said its new – and still experimental – Iron Dome missile defence shield intercepted one rocket fired at the southern city of Beersheba.
On Friday, the system intercepted three Grad rockets fired at the city of Ashkelon.
The exchange of blows came despite Hamas, the Islamist group which controls Gaza, saying on Thursday it had brokered a deal for the territory’s militant groups to stop firing on Israel.
Hamas’s military wing said it carried out some of the attacks on Israel, accusing Israel of breaking the ceasefire with its own raids.
On Friday, Israeli Prime Minister Benjamin Netanyahu vowed retaliation for the attack with an anti-tank missile on a school bus near the Nahal Oz kibbutz.
“The attack on a school bus crossed the line… Whoever tries to hurt and murder children, his blood will be on his own head,” Mr Netanyahu said.
A 16-year-old boy suffered serious injuries and the driver was also wounded.
Militants from the Qassam Brigades, the military wing of Hamas, hit the bus with an anti-tank shell.
This article is from the BBC News website. © British Broadcasting Corporation, The BBC is not responsible for the content of external internet sites.
