On New Year's Eve America was staring down the barrel of wide ranging spending cuts and tax hikes, if no deal could be done on imposing higher taxes on wealthy Americans.
Failure to agree a deal would have caused a recession.
The roots of the crisis date back to 2001, when President George W Bush passed a programme of tax cuts worth $1.7 billion. Separately, in 2011, President Barack Obama's administration tried to raise the US Government's borrowing limit – the "debt ceiling" set by statute – as part of a budget deal to tackle the US deficit.
But disagreements with Republicans over the government's borrowing levels led to a compromise that meant the debt ceiling was extended to December 31, 2012, the same day the Bush tax cuts expired.
What has been agreed?
The House of Representatives approved a Senate bill on Tuesday night to avert $600bn in automatic tax increases and spending cuts. The deal postpones the first automatic spending cuts for two months, while Congress works on a plan to replace them.
It raises $620bn in revenue over 10 years through tax increases on the wealthy.
It permanently extends tax cuts enacted in 2001 under George W Bush for income below $400,000 per individual, or $450,000 per family. Income above that level would be taxed at 39.6%, up from the current top rate of 35%.
Above that income threshold, capital gains and dividends tax rates would return to 20%, from 15%. It also caps personal exemptions and itemised deductions for income above $250,000, or $300,000 per household.
What happens next?
The agreement hands a clear victory to President Barack Obama, who won re-election on a promise to address budget woes in part by raising taxes on the wealthiest Americans. The deal also resolves, for now, the question of whether Washington can overcome deep ideological differences to avoid harming the economy.