WASHINGTON - Perilously close to a government shutdown, President Barack Obama and congressional leaders reached a historic agreement late Friday night to cut about $38 billion in spending and avert the first federal closure in 15 years.
Obama hailed the deal as "the biggest annual spending cut in history." House Speaker John Boehner said that over the next decade it would cut government spending by $500 billion - and won an ovation from his rank and file, tea party adherents among them.
"This is historic, what we've done," agreed Senate Majority Leader Harry Reid, D-Nev., the third man involved in negotiations that ratified a new era of divided government.
They announced the agreement less than an hour before government funding was due to run out, instantly turning hundreds of thousands of furlough notices for federal workers into historical relics.
The shutdown would have closed national parks, tax-season help lines and other popular services, though the military would have stayed on duty and other essential efforts such as air traffic control would have continued in effect.
On side issues - "riders," the negotiators called them - the Democrats and the White House rebuffed numerous Republican attempts to curtail the reach of the Environmental Protection Agency.
They also sidetracked their demand to deny federal funds to Planned Parenthood. Under the accord, the issue will come to a vote in the Senate under terms guaranteed to end in its defeat.
Anti-abortion lawmakers succeeded in winning a provision to ban the use of federal or local government funds to pay for abortions in the District of Columbia.
One of Boehner's priorities, a program that lets District of Columbia students use federally funded vouchers to attend private schools, was included.
In addition, the Senate will vote on proposals to deny federal funding to implement the year-old health care law. It is certain to fall short of the required 60 votes but will place Democrats on the record.
The long-term deal in hand, lawmakers raced to pass an interim measure to prevent a shutdown, however brief, and keep the federal machinery running for the next several days. The Senate acted within minutes, and even though it took the House longer. White House Budget Director Jacob Lew issued a directive saying that in view of the agreement, "agencies are instructed to continue their normal operations."
The deal came together after six grueling weeks and an outbreak of budget brinksmanship over the past few days as the two sides sought to squeeze every drop of advantage in private talks.
In one dramatic moment, Obama called Boehner on Friday morning after learning that the contours of the emerging deal they had reached with Reid in the Oval Office the night before had not been reflected in the pre-dawn staff negotiations.
The White House was baffled. The whole package was in peril of falling apart.
According to a senior administration official, Obama told Boehner that they were the two most consequential leaders in the United States government and that if they had any hope of keeping the government open, their discussions had to be honored and could not altered by staff. The official described the scene on condition of anonymity to reveal behind-the-scenes negotiations.
Despite the accomplishment, officials noted it marked only a first step. Republicans intend to pass a 2012 budget through the House next week that calls for sweeping changes in Medicare and Medicaid and would cut domestic programs deeply in an attempt to gain control over soaring deficits.
And the Treasury has told Congress it must vote to raise the debt limit by summer - a request that Republicans hope to use to force Obama to accept long-term deficit-reduction measures.
"We know the whole world is watching us today," Reid said earlier in a day that produced incendiary, campaign style rhetoric as well as intense negotiation.
Reid, Obama and Boehner all agreed a shutdown posed risks to an economy still recovering from the worst recession in decades.
But there were disagreements aplenty among the principal players in an early test of divided government - Obama in the White House, fellow Democrats in control in the Senate and a new, tea party-flavored Republican majority in the House.
"Republican leaders in the House have only a few hours left to look in the mirror, snap out of it and realize how positively shameful that would be," Reid said at one point, accusing Republicans of risking a shutdown to pursue a radical social agenda.
For much of the day, Reid and Boehner disagreed about what the disagreement was about.
Reid said there had been an agreement at a White House meeting Thursday night to cut spending by about $38 billion. He said Republicans also were demanding unspecified cuts in health services for lower income women that were unacceptable to Democrats.
"Republicans want to shut down our nation's government because they want to make it harder to get cancer screenings," he said. "They want to throw women under the bus."
Boehner said repeatedly that wasn't the case - it was spending cuts that divided two sides.
"Most of the policy issues have been dealt with, and the big fight is about spending," he said. "When will the White House and when will Senate Democrats get serious about cutting federal spending?"
By midday Friday, 12 hours before the funding would run out, most federal employees had been told whether they had been deemed essential or would be temporarily laid off in the event of a shutdown.
Obama canceled a Friday trip to Indianapolis - and a weekend family visit to Colonial Williamsburg in Virginia - and kept in touch with both Boehner and Reid.
The standoff began several weeks ago, when the new Republican majority in the House passed legislation to cut $61 billion from federal spending and place numerous curbs on the government.
In the weeks since, the two sides have alternately negotiated and taken time out to pass interim measures.
Originally, Republicans wanted to ban federal funds for Planned Parenthood, a health care services provider that is also the nation's largest provider of abortions.
Federal funds may not be used to pay for abortions except in strictly regulated cases, but supporters of the ban said cutting off government funds for the organization - currently about $330 million a year - would make it harder for it to use its own money for the same purpose.
Democrats rejected the proposal in private talks. Officials in both parties said Republicans returned earlier in the week with a proposal to distribute federal funds for family planning and related health services to the states, rather than directly to Planned Parenthood and other organizations.
Democrats said they rejected that proposal, as well, and then refused to agree to allow a separate Senate vote on the issue as part of debate over any compromise bill.
Instead, they launched a sustained campaign at both ends of the Capitol to criticize Republicans.
"We'll not allow them to use women as pawns," said Sen. Patty Murray, a fourth-term lawmaker from Washington who doubles as head of the Democratic senatorial campaign committee.
For Congress and Obama there are even tougher struggles still ahead - over a Republican budget that would remake entire federal programs, and a vote to raise the nation's debt limit.