Tea Party activists gather on Capitol Hill April 6, 2011 in Washington, DC. (BRENDAN SMIALOWSKI/AFP/GETTY IMAGES)

Congressional negotiators signed off Thursday evening on a $1 trillion spending agreement for 2012 for federal agencies, barely 27 hours before a deadline that could have led to a government shutdown.

After dropping minor policy prescriptions that President Obama opposed, members of the House and Senate Appropriations Committees gave final approval to the plan after a four-day standoff related to Obama’s demands to extend the payroll tax holiday for 160 million workers.

That negotiation, lawmakers and aides said, also could be headed toward an agreement, with lawmakers considering extending the $120 billion tax break for two months to buy more time to determine how they offset the benefit’s cost so it does not add to the federal deficit.

The White House initially had pushed Congress to delay the spending plan until the issue of the payroll tax was resolved, a move that raised the specter of a government shutdown and threatened to increase workers’ withholding tax at the start of the new year.

Linking the two measures only complicated the negotiations, however, and Republicans did not give in to Obama’s demands on how to set up the payroll tax provision. With the holiday season upon them, some aides suggested that lawmakers’ exhaustion and eagerness to leave the embattled Capitol for several weeks served as key factors in reaching the deals. Next year’s session will begin in late January.

“In spite of many unnecessary obstacles, it is good to see that responsible leadership and good governance can triumph,” House Appropriations Chair­man Harold Rogers (R-Ky.) said Thursday night, referring to the spending plan.

The legislation will provide the full funding for the rest of fiscal 2012 for most of the government, including the Pentagon, the Education Department and the Environmental Protection Agency.

Now that the spending deal has been clinched — votes are expected in both chambers Friday — the payroll tax issue remains the last fight for the acrimonious first session of the 112th Congress, one that has been marked by repeated brinkmanship.

After several days of trading blame on both issues, there was a broad shift in tone Thursday morning in negotiations on the tax plan. Senate Majority Leader Harry M. Reid (D-Nev.) predicted the impasse would be resolved soon. And House Speaker John A. Boehner (R-Ohio) told everyone to “step back and take a deep breath.”

“I think there’s an easy way to untangle all of this,” Boehner said. “We just need to let the members do their jobs, and we need to let the two institutions do their work.”

Talks on the payroll tax holiday lasted deep into Thursday night. They had picked up steam 24 hours earlier, when Democrats dropped their demand that the cut be paid for with a new surtax on those who earn more than $1 million a year.

“Yeah, that’s gone,” Senate Finance Committee Chairman Max Baucus (D-Mont.) confirmed Thursday evening. Baucus, who is negotiating the tax package for Democrats, continued pushing to complete a year-long extension of the payroll tax provision, coupled with extended un­employment benefits and an important tweak to the Medicare reimbursement rate for doctors.

“There’s momentum building toward a comprehensive agreement, but still there are a lot of pieces to put together,” Baucus said.

But senior Democratic and Republican aides said an agreement had been secured to at least continue the tax break for two months, at a cost of $40 billion. Among the ideas being considered to pay for the cut, aides said, were raising fees Fannie Mae and Freddie Mac collect from lenders and ending a tax break on the sale of corporate jets.

Extending the payroll tax cut has become politically critical for Obama, the only major piece of his roughly $450 billion jobs plan that is likely to win approval. As part of a separate tax deal a year ago, the federal withholding tax dropped from 6.2 percent to 4.2 percent in 2011, which gave the average worker an extra $1,000, and the president has argued that continuing the holiday for another year would help steady the economy.

In exchange for agreeing to that extension, Republicans continued to insist on concessions intended to lure votes from conservatives who say the tax holiday is bad economic policy. Their most important demands were speeding up approval of the construction of the controversial Keystone XL oil pipeline, reforms to unemployment insurance, higher Medicare premiums for upper-income seniors and a year-long extension of a two-year pay freeze for federal workers.

Baucus said one consideration was to link the eligibility period of unemployment benefits to the level of joblessness in each state. Republicans remained publicly quiet about the proposal to temporarily extend the tax break, but one senior GOP adviser noted that it would lead to two more months of Republicans pushing for the oil pipeline.

The hardball tactic of linking tax-holiday negotiations — as well as jobless benefits — to the completion of the must-pass spending bill irritated some Democrats who had worked with Republicans for months to reach the appropriations deal.

Rep. James P. Moran (D-Va.), who sits on the key committee, said some Democrats had told the White House that “they should not be using federal employees as pawns in a larger issue.”

“I don’t blame them for trying to use every means available to them,” he said. “But I just don’t think that it’s right.”

While seeking leverage on the tax dispute, the White House also expressed lingering concerns about some of the policy items in the spending bill, including restrictions on travel to Cuba and a minor provision related to oversight of financial trades. The spending agreement Thursday eliminated language that would have limited trips to Cuba to once every three years for those with family living there, and would have placed stricter limits on remitting money to relatives on the island.

Remaining in the legislation is a ban on the District spending local tax money on abortion.

The funding bill sets government spending for the year at $1.043 trillion, a level agreed to in an August deal that raised the nation’s legal borrowing limit. The figure represents a 1.5 percent drop in spending from the fiscal year that ended Sept. 30.

That doesn’t count $115 billion for overseas military operations, a $43 billion dip since this past year as the war in Iraq winds down. It also doesn’t include $8.1 billion in emergency disaster-relief spending.

The measure outlines spending for three-fourths of the government — all but the departments of Agriculture, Commerce, Housing and Urban Development, Justice, State, and Transportation, as well as NASA and some smaller agencies — which were settled in a November deal.

As Congress works to lower the federal deficit and reduce government spending, most domestic programs will see cuts.

The measure omits funding for the Internal Revenue Service to prepare for the 2014 implementation of the federal health-care law. But it increases funding for border agents and Immigration and Customs Enforcement.

It includes $8.4 billion for the EPA — a $233 million drop from last year. And provides $550 million for Obama’s signature Race to the Top education program, a cut of more than 20 percent.

Staff writer Felicia Sonmez contributed to this report.

Read more on PostPolitics.com

Gingrich on the defensive in Iowa debate

The Fix: The Kumbaya debate

Fact checking the GOP debate in Iowa