Facing withering criticism from across the political spectrum and abandoned by Senate allies, House Republicans bowed to political reality Thursday and agreed to a two-month extension of a payroll tax cut for 160 million Americans.

The agreement represented a remarkable capitulation on the part of House Republicans, who had two days earlier rejected such a deal with Democrats as the kind of half-measure that their new majority was elected to thwart.

And it amounts to a Christmas gift for President Obama, who attempted to paint his Republican opponents as willing to raise taxes for millions of Americans. Such an image could have cost the party politically just as it is gearing up to try to take back the White House and the Senate in 2012.

The agreement resolved the last stalemate in a year of bitter congressional fighting that earned lawmakers their lowest approval ratings in recent memory.

In exchange for supporting the 60-day patch, Republicans secured minor face-saving concessions from Senate leaders, who had already passed a two-month deal on an overwhelming vote of 89 to 10. Senate leaders had balked at the House’s demand to restart talks over the holidays on a full-year extension of the tax cut.

The Senate agreed to make a technical change to the payroll tax reporting requirements, designed to lessen the burden on small businesses of implementing the two-month deal.

And Senate Majority Leader Harry M. Reid (D-Nev.) promised he would appoint a conference committee to take up negotiations after New Year’s Day on ways to pay for a full-year tax cut.

Reid and Obama have been pushing for a full-year tax relief package for weeks. Republicans, on the other hand, have been divided over whether a payroll tax holiday is a good way to stimulate the economy.

Congressional leaders said they expected to ratify the deal in voice votes on Friday that will require only a handful of members to be in Washington.

Under the agreement, benefits for the long-term unemployed will also be extended for two months and scheduled cuts in reimbursements to doctors who serve Medicare patients will be postponed. The $33 billion package will be funded by increasing the fees that Fannie Mae and Freddie Mac charge lenders for guaranteeing home loans.

Obama had insisted the Senate’s two-month deal was the only way to prevent payroll taxes from leaping from 4.2 percent to 6.2 percent next month for 160 million workers. He had secured the original, year-long break in the payroll tax last December and argued that the extension was necessary to boost the economy.

“This is good news, just in time for the holidays,” the president said in a statement Thursday evening. “This is the right thing to do to strengthen our families, grow our economy, and create new jobs. This is real money that will make a real difference in people’s lives. ”

He credited public pressure — which was fanned by the White House — with changing the House’s position.

Boehner said he was convinced by fellow House members that although a short-term deal was not ideal, they should support it if they could get the change to the payroll tax reporting requirements.

“I talked to enough members over the last 24 hours who believe that, ‘Hey, listen, we don’t like this two-month extension, we don’t like this reporting problem in the Senate bill,’ ” he said Thursday evening. “But if you get this fixed, why not, why not do the right thing for the American people, even though it’s not exactly what we want.”

Only hours before accepting the deal, Boehner had appeared to stiffen his opposition to it, appearing with House Majority Leader Eric Cantor (Va.) and a handful of other House Republicans who had been tapped to remain in town to rework a deal with the Senate.

“We’re fighting to do the right thing,” he said.

But then Senate Minority Leader Mitch McConnell (R-Ky.) issued a statement urging the House to accept the two-month deal first and then turn to discussions about the rest of the year.

House Republicans “sensibly want greater certainty about the duration of these provisions, while Senate Democrats want more time to negotiate the terms,” McConnell said. “These goals are not mutually exclusive. We can and should do both.”

And as the day wore on, a number of House members broke ranks and urged the speaker to let the House accept the 60-day deal.

“Washington’s dysfunction shouldn’t dictate a tax increase on my constituents,” said Rep. Sean Duffy (Wis.), one of the most politically vulnerable of the nearly 90 House Republican freshmen. He had previously voted to reject the Senate deal.

Senate leaders expressed relief that the House had come around. Reid said he was “grateful the voices of reason have prevailed and Speaker Boehner has agreed to pass the Senate’s bipartisan compromise.”

McConnell said Obama’s statements in the past week “castigating House Republicans” amounted to “the kind of unhelpful political opportunism Americans are tired of” and accused Obama of failing to broker long-term economic solutions. But he, too, said he was pleased with the outcome.

The two-month arrangement had been crafted by McConnell and Reid after talks fell apart in the Senate over how to pay for a $200 billion year-long package.

Republicans had sought to impose higher Medicare premiums on upper-income senior citizens while Democrats wanted to close tax loopholes for the wealthy. They will return to that impasse in January.

But Republicans believed they wrested a key concession from Democrats — a provision that requires Obama to decide in 60 days whether to allow construction of an extension of the controversial Keystone XL oil pipeline.

McConnell had apparently believed initially that the House would quickly sign off on the Senate deal. Instead, the House rank-and-file exploded with fury in a conference call last Saturday, insisting that their own, previously approved bill to maintain the tax cut for another year was better. That bill would have extended a freeze on federal workers’ salaries and put more limits on a continuation of unemployment insurance.

On Tuesday, the House voted 229 to 193 to set aside the Senate’s deal and request that the Senate form a conference committee to work out differences between the two chambers’ versions of the legislation.

But Reid charged that Boehner was walking away from what was already a bipartisan agreement, and it became clear that he would not appoint Senate conferees.

House Republicans started taking fire from conservative opinion makers for somehow allowing their party to appear on the wrong side of a tax cut.

“This is like poker. You’ve got to know when to hold and know when to fold,” said Rep. Tom Cole (R-Okla.).

Staff writers Felicia Sonmez, Paul Kane and David Nakamura contributed to this report.