With barely a day to act, the polarized US House of Representatives approved a massive austerity plan to avert a debt default that would have wreaked havoc through the global economy.
After eight months of often angry negotiations, the Republican-led House voted 269-161 on a package backed by President Barack Obama to raise the limit on US borrowing and enact at least $2.1 trillion in spending cuts over the next decade.
The Democratic-led Senate was expected to approve the emergency measure in a noon (1600 GMT) vote Tuesday -- scarcely 12 hours before a midnight deadline by which the world's richest nation would run out of cash to pay its bills.
"It is imperative that the United States not default on the nation's obligations, that the full faith and credit of the United States be preserved, and that the nation's fiscal house be put in order," the White House said.
In a moment of high drama -- an rare show of unity in the ideologically torn Congress -- Democratic Representative Gabrielle Giffords drew applause and cheers from her assembled colleagues as she made a triumphant first return since being shot in the head in a January shooting rampage in her home state of Arizona.
But the vote showcased many of the political fault lines likely to shape Obama's November 2012 re-election bid, notably conservative Republicans' all-out push to cut government spending, and Democrats' quest to raise taxes on the rich.
The vote was a key test for House Speaker John Boehner, a Republican, who said before the vote that the package would start "fixing our fiscal problems" and "provide more confidence for employers in America."
"The process works. It may be messy, but it works," Boehner told CNN in brief remarks after the vote.
The ultraconservative "Tea Party" among Republicans had demanded a hard line. Tea Party favorite Michele Bachmann opposed the deal as too tepid, although other members of the movement called the deep spending cuts a triumph.
Republicans backed the plan 174-66, while Democrats denied a Democratic president a majority of their votes, splitting evenly 95-95 on the measure after many of them waited until the last minute to cast their ballots.
Liberal Democrats were outraged at what they saw as an abandonment by Obama of core principles. Representative Nancy Pelosi, the top House Democrat and member of the party's left-wing flank, took to the floor before the vote and pleaded with her colleagues to consider supporting the package.
"I'm not happy with it," she said, but "please think of what could happen if we defaulted. Please, please, please come down in favor of preventing the collateral damage to our seniors and our veterans."
Liberals were aghast that the plan relied on spending cuts and did not include increases in tax revenues from the rich and wealthy corporations, although Obama has called for letting tax cuts for the top brackets expire in January 2013.
"This deal is a sugar-coated Satan sandwich. If you lift the bun, you will not like what you see," Democratic Representative Emanuel Cleaver, who heads the Congressional Black Caucus, said on his Twitter feed.
Financial markets also showed concern, with early optimism evaporating by midday on worries the deal could fail to prevent a downgrade of Washington's top Triple-A debt rating.
A downgrade could push up US interest rates, making debt payments more expensive and affecting any flexible-rate loan in the sputtering US economy, still grappling with historically high unemployment of 9.2 percent.
European share prices slumped sharply, but Wall Street recouped early losses. Shares opened lower Tuesday in Tokyo but largely over speculation that Japan will intervene to weaken the strong yen, dealers said.
Russia and China, often on the receiving end of US criticism, have been critical of the debt talks. Russian Prime Minister Vladimir Putin accused the United States of acting as a "parasite" living off its creditors.
US Vice President Joe Biden, a 36-year veteran of the Senate, held talks on Capitol Hill to press fellow Democrats to back the deal, fruit of six months of fitful talks between President Barack Obama and his Republican foes.
Emerging from closed-door talks with House Democrats, Biden said he had gotten an earful of their "frustration" but that there was a "a sword of Damocles hanging over everyone's heads."
The blueprint negotiated between Obama and congressional leaders would include more than $900 billion in cuts over the next 10 years -- $350 billion of it in defense. A special congressional committee would then be tasked with coming up with another $1.5 trillion in cuts to report by November 23.
A failure by the committee would trigger automatic cuts -- half in defense spending, a priority for many Republicans. Automatic cuts would not touch Democratic-backed Social Security and Medicare payments for the elderly, although they would still affect providers of the health care program.
In a key point for Obama, the package will raise the debt ceiling into 2013 --- meaning he will not be forced into a similar showdown with Congress on spending in the midst of his re-election campaign next year.
The debt ceiling would rise by up to $2.4 trillion in two steps. The US government hit its current debt limit of $14.3 trillion on May 16 and has since been operating through spending and accounting adjustments, as well as higher than expected tax revenue.