Months of brinkmanship, weeks of infighting, and the spectre of economic disaster. A deal to avoid the US falling off the fiscal cliff has finally been agreed. But the battle certainly isn't over yet.

Please wait while this video loads. If it doesn't load after a few seconds you may need to have Adobe Flash installed.

So the US fiscal cliff has been avoided - or rather, postponed for a couple of months after a last-ditch deal was clinched in Washington. Global share prices have already rallied on the news that this is not to be a story of financial calamity.

But instead, there's a story to be told of what happened to a party which publicly pledged never to vote for tax rises; a leader accused of running a "dictatorship" and being more interested in his own job than the long term needs of the country, and another party whose bitter infighting meant a deal that so many found unacceptable finally got approved.

Most people were out celebrating new year's day when the drama on Capitol Hill was reaching its climax. At stake, a hard-won agreement to prevent massive tax hikes and spending cuts which would have affected almost every American. And a Republican party whose votes were by no means assured.

The Senate had already approved a compromise deal which involved a major concession by the GOP, allowing taxes to rise on individuals earning more than $400,000 a year - a threshold way higher than Obama's election pledge of $250,000, but a figure many in the party were unwilling to accept.

The Republicans weren't the only ones unwilling to stomach such concessions. The top Democrat in the Senate, Harry Reid, was privately set against it, believing it would give far greater bargaining power to the GOP in future budget negotiations.

The deficit needs to be reduced in a way that is balanced. Everyone pays their fair share. Barack Obama

But as the president pushed ahead, regardless - the relationship between the party leaders was at an all time low. Politico reported that at one stage, tensions rose so high, that House Speaker John Boehner publicly told Reid to go f*** himself.

In the end, Joe Biden was called in to corral the Democratic caucus behind the compromise deal, which passed the Senate by 89 votes to 9. The House of Representatives was less straightforward.

John Boehner wanted to accept it: after all, the alternative seemed far worse for his party, who would take full blame if the huge tax rises and spending cuts were triggered. But in 2010 the GOP had run on a platform of rejecting any tax increase, even for that top 0.6 per cent of earners on more than $400,000.

They wanted to hold out for steep public spending cuts, and they hadn't got them. Steve LaTourette, of Ohio, dismissed the Senate vote out of hand: "We should not take a package put together by a bunch of octogenarians on new year's eve," he declared.

There were plenty of Democrats who were left unimpressed: former labour secretary Robert Reich dubbed it a "lousy deal", while economist Jared Bernstein, who formerly worked for vice president Biden, wrote that it "meets the Republicans further on their side of the field than one might have expected, given the White House's leverage."

The ayes have it

In the end, enough representatives from both parties lined up behind the deal, which went through by 257 to 167 although Republican House leader Eric Cantor and the party's chief whip Kevin McCarthy were among those who voted against it.

President Obama declared a major victory, on an important point of principle: "Today's agreement enshrines, I think, a principle into law that will remain in place for as long as I am president. The deficit needs to be reduced in a way that is balanced. Everyone pays their fair share....That is how our economy works best."

But the last minute compromise leaves many key questions unanswered. The fiscal cliff deal cuts spending by just $12bn, and raises revenue by $620bn: yet this is small change when faced with the $16.4tr debt ceiling, which was reached on Monday.

It's wrong, and I'm saying that as a member of the Republican party. Peter King on the failure of the Sandy relief bill

The debate over the debt ceiling is looming fast. It comes at the end of February, when the delay on the massive spending cuts and tax hikes known as the sequester will also run out. If you thought the fiscal cliff shenanigans were apocalyptic enough, just wait for the fight to come.

Obama is adamant that it won't be up for negotiation.

"I will not have another debate with this congress over whether or not they should pay the bills that they've already racked up," he said.

"If congress refuses to give the US government the ability to repay these bills on time, the consequences for the global economy would be catastrophic - far worse than a fiscal cliff."

But he may not have much room to manoeuvre. The congressional budget office estimates that the compromise deal will rack up an additional $4tr in debt over the next ten years. That brings the president under pressure to tackle those two biggest sources of public spending - Medicare and social security.

Sandy relief aid scrapped

There has already been one casualty of all that infighting over the fiscal cliff: a bill to grant some $60bn in disaster relief aid to the communities hit by superstorm Sandy. Congress ended its session without voting on the measure.

The 113th congress will be sworn in on Thursday, but it can't simply take up a piece of legislation from the last one without starting again from scratch. Republicans from affected areas were furious.

"For the Speaker to just walk out is inexcusable," railed Peter King, of New York.

"It's wrong, and I'm saying that as a member of the Republican party."

Fellow representative Michael Grimm called it a personal betrayal.

"When you parse out all the politics, the people of this country that have been devastated are looking at this as a betrayal by congress and by the nation, and that is just untenable and unforgivable."

According to the GOP, the bill contained billions of dollars in spending on various infrastructure and other projects that was entirely unconnected to the storm damage. Democrats claimed the victims would not even begin to be able to rebuild without the prospect of future cash.

And although low tax rates for the less well-off will now be protected, working families will still see about $2,000 taken out of their annual salaries, because a rise in payroll tax increases will now be resumed.

The grand bargain may not turn out to be such a bargain, after all.

Felicity Spector writes about US politics for Channel 4 News.