The dramatic resolution lifted a cloud that had threatened the still-fragile economic recovery at home - and it instantly powered a rise in financial markets overseas.
The agreement would slice at least $2.2 trillion from federal spending over a decade, a steep price for many Democrats, too little for many Republicans. The Treasury's authority to borrow would be extended beyond the 2012 elections, a key objective for Obama, though the president had to give up his insistence on raising taxes on wealthy Americans to reduce deficits.
The deal, with scant time remaining before Tuesday's debt-limit deadline for paying government bills, "will allow us to avoid default and end the crisis that Washington imposed on the rest of America," the president said in an announcement at the White House.
Default "would have had a devastating effect on our economy," he said.
House Speaker John Boehner telephoned Obama at mid-evening to say the agreement had been struck, then immediately began pitching the deal to his fractious rank and file.
"It isn't the greatest deal in the world, but it shows how much we've changed the terms of the debate in this town," he said on a conference call, according to GOP officials. He added the agreement was "all spending cuts. The White House bid to raise taxes has been shut down."
The House Democratic leader, Rep. Nancy Pelosi, was noncommittal. "I look forward to reviewing the legislation with my caucus to see what level of support we can provide," she said in a written statement.
Many economists have expressed concerns that the spending cuts could threaten an already feeble economic recovery. The first half of 2011 marked the worst six-month economic performance since the Great Recession officially ended in June 2009.
No votes were scheduled in either house of Congress before Monday, to give rank and file lawmakers time to review the package. Senate approval seems virtually certain; the House could prove more difficult.
Without legislation in place by Tuesday, the Treasury would not be able to pay all its bills, raising the threat of a default that administration officials say could inflict catastrophic damage on the economy.
If approved, though, a compromise would presumably preserve America's sterling credit rating, reassure investors in financial markets across the globe and possibly reverse the losses that spread across Wall Street in recent days as the threat of a default grew.
Even word of an impending deal earlier in the day by Senate Republican Leader Mitch McConnell of Kentucky sent U.S. stock futures upward. And before Obama had finished speaking, Japan's benchmark Nikkei index, opening Monday morning - at 8 p.m. Sunday on America's East Coast - was up 1.7 percent in early trading.
Not that the deal would end the political maneuvering. While eliminating the threat of default, it creates a remarkably short timetable for Congress to debate a huge and politically bruising deficit-reduction plan. The plan would require a committee of lawmakers to come up with $1.5 trillion more in deficit cuts from benefit programs or tax reform before Thanksgiving. Congress must vote on them by Christmas - or trigger across-the-board cuts that would hit the Pentagon and domestic programs.
Pending final passage, the agreement marked a dramatic reach across party lines that played out over six months and several rounds of negotiating, interspersed by periods of intense partisanship.
"Sometimes it seems our two sides disagree on almost everything," Senate Majority Leader Harry Reid said in floor remarks.
"But in the end, reasonable people were able to agree on this: The United States could not take the chance of defaulting on our debt, risking a United States financial collapse and a world-wide depression."
Vice President Joe Biden, who played an important part in this weekend's negotiations, agreed. He tweeted, "Compromise makes a comeback."
Not everyone felt that way.
"Someone has to say no. I will," said Rep. Michele Bachmann, R-Minn., a contender for the 2012 Republican presidential nomination.
Across the weeks, Boehner emerged as Obama's principal Republican antagonist in a contentious new era of divided government, yet struggled to corral his own rank and file at times.
At the end, though, McConnell and Biden, who looked on as Obama announced the deal, provided a negotiating channel to get the deal completed, overcoming a last-minute standoff over the impact of spending cuts on the Pentagon budget.
The plan calls for spending cuts and increased borrowing authority for the Treasury in two stages.
In the first, passage of the legislation would trigger more than $900 billion in spending cuts over a decade as well as a $900 billion increase in the government's borrowing authority.
The spending cuts would come from hundreds of federal programs across the face of government - accounts that Obama said would be left with the lowest levels of spending as a percentage of the overall economy in more than a half-century.
The increased borrowing authority includes $400 billion that would take effect immediately, and $500 billion that would be permitted after Congress had a chance to block it.
In the second stage, a newly created joint committee of Congress would be charged with recommending $1.5 trillion in deficit reductions by the end of November that would be put to a vote in Congress by year's end. The cuts could come from benefit programs such as Medicare, Social Security and Medicaid as well as from an overhaul of the tax code.
The committee proposals could trigger a debt limit increase of as much as $1.5 trillion, if approved by Congress. But if they do not materialize, automatic spending cuts would be applied across government to trim spending by $1.2 trillion.
Social Security, Medicaid and veterans' benefits would be exempt from the automatic cuts, but payments to doctors, nursing homes and other Medicare providers could be trimmed, as could subsidies to insurance companies that offer an alternative to government-run Medicare.
The deal marked a classic compromise, a triumph of divided government that would let both Obama and Republicans claim they had achieved their objectives.
As the president demanded, the deal would allow the debt limit to rise by enough to tide the Treasury over until after the 2012 elections.
But Obama's request to extend the current payroll tax holiday beyond the end of 2011 would not be included, nor his call for extended unemployment benefits for victims of the recession.
Republicans would win spending cuts of slightly more than the increase in the debt limit, as they have demanded. Additionally, tax increases would be off limits unless recommended by the bipartisan committee, which is expected to include six Republicans and six Democrats. The conservative campaign to force Congress to approve a balanced-budget amendment to the Constitution would be jettisoned.
Congressional Democrats have long insisted that Medicare and Social Security benefits not be cut, a victory for them in the proposal under discussion. Yet they would have to absorb even deeper cuts in hundreds of federal programs than were included in legislation they had advanced in the final days before an agreement was reached.
Associated Press writers Ben Feller, Jim Abrams, Laurie Kellman and Andrew Taylor contributed to this story.