(Reuters) - Congress approved a two-month payroll tax cut extension on Friday, capping an exhausting year of partisan warfare over taxes and spending that will resume in January, with the economy barely scratching out a recovery and elections on the horizon.

Both the Senate and the House of Representatives, by voice votes in chambers nearly emptied for the holidays, passed a $33 billion measure to keep the payroll tax rate at 4.2 percent until the end of February. It had been slated to increase after December 31 to 6.2 percent.

The temporary fix lets lawmakers draw down the curtain, for now, on weeks of partisan deadlock that in the end produced only another inconclusive truce in a debate over taxes and spending that is set to rage straight through 2012.

The temporary payroll tax fix gives President Barack Obama and the Democrats a political win over Republicans. The 2012 election cycle is about to kick off with the January 3 Iowa Republican presidential caucus, but a long road lies ahead until voters go to polls in November.

House Republicans backed down late on Thursday from their opposition to the two-month extension, clearing the way for Friday's action.

Unemployment benefits that had been set to expire soon were extended as well, while cuts in payments to doctors who treat patients in the government-backed Medicare health insurance program for the elderly were also postponed, under the measures.

An increase in the payroll tax would have hit the wallets of 160 million U.S. workers at a time of high unemployment and deep voter dissatisfaction with the tax system, the shape of the economy and the way Congress conducts itself.

Analysts had warned that failing to renew the tax cut could jeopardize the economic recovery, perhaps even risking another recession.

House Speaker John Boehner, the top U.S. Republican, yielded to pressure from Democrats and his party and agreed, with minor changes, to allow a vote on the extension bill passed by the Senate last week with bipartisan support.

The two-month deal came after lawmakers were unable to agree on ways to offset the costs of a full-year payroll tax cut extension. The temporary extension legislation was expected to be sent to Obama to sign into law before December 31.

Democratic Representative Chris Van Hollen said on Friday the two parties remained far apart on how to pay for a full-year fix.

I heard Eric Cantor (the No. 2 Republican in the House) at one point say the parties are really close on the one-year deal. That's just not the case, Van Hollen told MSNBC.