The White House and top Republicans struck a dramatic deal to avert huge New Year tax hikes and spending cuts known as the "fiscal cliff" that had threatened to send the US economy into recession.
The pact, if agreed by Congress, would hand President Barack Obama a victory by hiking tax rates on the wealthy - households earning over $450 000 a year - but exempt everyone else from a planned tax increase on Tuesday.
It would also put off $109-billion in budget cuts across the government for two months, but in the process set the stage for a new showdown between Obama's Democrats and Republicans in dysfunctional Washington at the end of February.
Vice President Joe Biden, who negotiated the deal with the top Republican in the Senate Mitch McConnell, was on Capitol Hill to sell it to Democratic senators, some of whom wanted tax hikes to kick in at a lower threshold.
Had no deal been struck, budget experts warned that the fragile US economy could have been sent spinning back into recession by the $500-billion combined whack from spending cuts and tax hikes.
In the end, the deal was clinched just a few hours before a midnight deadline. A Senate vote was planned within hours, while the House of Representatives was not due back into session until Tuesday.
"I feel very good about how this vote could go," Biden said before senators weighed in on the bill, though adding that he would not predict exactly how the two chambers would vote.
"I feel very, very good. I think we'll get a very good vote tonight."
Now it remains for Republican House Speaker John Boehner to rally his restive conservative coalition around the agreement, which will likely need some Democratic votes in the House to pass.
For two decades, Republicans have fought any attempt to raise taxes so White House officials will see vindication in a deal that enshrines one of Obama's top pledges in his re-election campaign.
In a terse statement, Boehner and fellow House Republican leaders said that his chamber would pick up the legislation if it passed the Senate.
"Decisions about whether the House will seek to accept or promptly amend the measure will not be made until House members - and the American people - have been able to review the legislation," Boehner said.
Democrats suggested that the deal, like many congressional bargains, was not perfect, but that it was preferable to the alternative.
"It's not that this proposal is regarded as great or is loved in any way. But it's a lot better than going over the cliff," Senator Chuck Schumer told reporters.
Democratic Senator Dianne Feinstein added: "once the grand bargain was not able to be realised, you had to get what was necessary to get us past the so-called cliff."
World stock markets, expected to be thrown into turmoil by a failure to beat the midnight deadline, are closed for New Year's Day, so lawmakers have a few extra hours of breathing room to get the deal concluded.
The deal means a return to Bill Clinton-era tax rates for top earners to 39.6 percent, starting for individuals who make $400 000 a year and couples who make $450,000 a year and above.
Obama had originally campaigned for tax hikes to kick in for those making $250 000 and above.
The president said earlier that the deal would extend tax credits for clean energy firms and also unemployment insurance for two million people that had been due to expire.
It was also includes an end to a temporary two percent cut to payroll taxes for Social Security retirement savings and Medicare health care programs for seniors and changes to inheritance and investment taxes.
A source familiar with the deal said that the two-month delay to spending cuts - known as the sequester - was financed by increased revenues and spending cuts from defense and non-defense spending.
Both Democratic House Minority Leader Nancy Pelosi and Senate Majority Leader Harry Reid had signed off on the deal, the source said.
Earlier, on a day of drama and brinkmanship, Obama had angered Republicans in remarks in which he warned that he was not done with seeking higher taxes on the rich to pay down the US budget deficit.
"Now, if Republicans think that I will finish the job of deficit reduction through spending cuts alone... then they've another thing coming," Obama said, while poking fun at the glacial pace of congressional deliberations.
Republican Senator Bob Corker said his heart pounded with disappointment at Obama's remarks.
"I know the president has fun heckling Congress. It's unfortunate he doesn't spend as much time solving problems as he does with campaigns and pep rallies."
Signs that a deal could be close cheered investors as US markets rose before closing for the year. The Dow Jones Industrial Average closed up 166.03 points (1.28 percent) at 13,104.14.
Both sides were already gearing up for the next legislative showdown over the need to lift the government's statutory borrowing limit of $16.4-trillion, reached Monday.
The Treasury will take extraordinary measures to keep the government afloat for an undisclosed period of time until the ceiling is raised. Republicans are already demanding spending cuts in return.
That fight will now be doubled, with the deadline for the two-month postponement of the sequester set up by the fiscal cliff agreement.