The Senate moved the US economy back from the edge of a "fiscal cliff", voting to avoid imminent tax hikes and spending cuts in a bipartisan deal that could still face challenges in the House of Representatives.

In a rare New Year's session, which finished at around 2am yesterday, senators voted 89-8 to raise some taxes on the wealthy while making permanent low tax rates on the middle class that have been in place for a decade.

But the measure did little to rein in huge annual budget deficits that have helped push the US debt to $16.4 trillion.

The agreement came too late for Congress to meet its own deadline of New Year's Eve for passing laws to halt $600 billion in tax hikes and spending cuts which strictly speaking came into force yesterday.

But with the New Year's Day holiday, there was no real world impact and Congress still had time to draw up legislation, approve it and backdate it to avoid the harsh fiscal measures.

That will need the backing of the House where many of the Republicans who control the chamber complain that President Barack Obama has shown little interest in cutting government spending and is too concerned with raising taxes.

Mr Obama called for the House to act quickly and follow the Senate's lead. He said: "While neither Democrats nor Republicans got everything they wanted, this agreement is the right thing to do for our country and the House should pass it without delay. There's more work to do to reduce our deficits, and I'm willing to do it. But tonight's agreement ensures that, going forward, we will continue to reduce the deficit through a combination of new spending cuts and new revenues from the wealthiest Americans."

But if politicians cannot pass legislation in the coming days, markets are likely to turn sour and the US economy could stall again. Majority Leader Harry Reid, a Democrat, told the Senate floor: "If we do nothing, the threat of a recession is very real. Passing this agreement does not mean negotiations halt, far from it."

A new, informal deadline for Congress to legislate is set for today when the current body expires and it is replaced by a new Congress chosen at last November's election.

The Senate bill, worked out after long negotiations on New Year's Eve between Vice-President Joe Biden and Senate Republican Minority Leader Mitch McConnell, also postpones for two months a $109 billion "sequester" of sweeping spending cuts on military and domestic programs.

It extends unemployment insurance to two million people for a year and makes permanent the alternative minimum tax "patch" that was set to expire, protecting middle-income Americans from being taxed as if they were rich. The tax hikes do not sit easy with Republicans but conservative senators held their noses and voted to raise rates for the rich because not to do so would have meant increases for almost all working Americans.

Mr McConnell said: "It took an imperfect solution to prevent our constituents from a very real financial pain, but in my view, it was worth the effort."

House Speaker John Boehner – the top Republican in Congress – said the Senate left open the possibility of the House amending the bill, which would spark another round of legislating.

"The House will honour its commitment to consider the Senate agreement if it is passed. Decisions about whether the House will seek to accept or promptly amend the measure will not be made until House members ... have been able to review the legislation," Mr Boehner and other House Republican leaders said in a statement.