The U.S. Senate OK'd on Saturday a $1 trillion bill to fund the government and a two-month extension of the payroll-tax cut, capping a contentious political year while preparing the arena for a fresh battle in 2012.

Democrats and Republicans were unable to agree on how to cover the cost of extending payroll-tax cuts and long-term unemployment benefits for a full year, as President Barack Obama requested. So senators settled for a two-month extension that ensures another round of debate early next year -- just as the presidential and congressional election campaigns shift into high gear.

It would be inexcusable for Congress not to further extend this middle-class tax cut for the rest of the year, Obama said at the White House shortly after the Senate passed the two-month payroll-tax cut extension. The Senate then left town, to return in late January.

Obama is expected to promptly sign into law the $915 billion spending bill that raises funding for the Defense Department but cuts into budgets at the Environmental Protection Agency, education and health departments, and other federal entities.

Congress went down to the wire to finish the legislation, as agency funds were running out this weekend and federal workers faced layoffs.

The payroll-tax cut bill still must be approved by the House of Representatives. Kevin Smith, a representative of Speaker of the House John Boehner, R-Ohio, said he could not comment on the bill's prospects until leaders consulted with Republican members.

The White House and many private economists have warned that a failure to extend the workers' tax cut for a year could hurt the economy at a vulnerable time.

Republicans used the tax bill to try to win quick U.S. approval of the TransCanada Corp.'s Keystone XL pipeline project.

Tucked into the legislation is a provision requiring Obama to either approve the pipeline construction from Canada to U.S. Gulf of Mexico facilities in Texas within 60 days or declare that the project is not in the national interest.

Obama wanted to take a year, beyond next November's elections, to review the routing of the pipeline.

But Republicans in Congress, who were tepid to continuing a 4.2 percent payroll tax on workers (versus the regular 6.2 percent), demanded fast action on Keystone. They argued it would create construction jobs, helping an economy suffering from high unemployment.

The president says he wakes up every morning thinking about jobs. This morning, the Senate took action where the president has punted, said Sen. John Cornyn, R-Texas, referring to the Keystone pipeline jobs he said would be created by the Senate-passed bill.

Democratic Sen. Charles Schumer of New York characterized his party's concession on Keystone as giving Republicans the sleeves off a vest since the State Department already has said it would withhold approval if forced to fast-track a decision.

He also told reporters that the main concern for middle-class Americans was continuing the payroll-tax cut.

Higher Mortgage Fees

The payroll-tax cut bill's $33 billion cost over two months would be covered over 10 years by increasing fees that government-backed Fannie Mae and Freddie Mac charge lenders or mortgage customers. In turn, that  will increase consumers' payments on new home mortgages.

For example, the cost of a $220,000 mortgage would go up by about $15 per month, according to Obama administration calculations.

The administration had proposed to increase the so-called guarantee fee Fannie and Freddie charge lenders as a way to slash the federal budget deficit and shrink the government's role in the housing market.

It was not clear how the higher guarantee fee would affect the country's housing market, which is struggling to recover.

In a year that saw relentlessly partisan fights over budget, debt, and tax legislation, the payroll-tax cut and jobless-benefits measure resulted in a final bruising battle that could set the tone for next year.

It was such a difficult year that Senate Majority Leader Harry Reid, D-Nev., tried to put some historical perspective on it and remind Americans that things could have been worse.

Reid recounted the 1856 beating in the Senate chamber of a senator by a member of the House of Representatives. The times that we are going through here are not unusual for the United States Senate, Reid said, adding, In fact, they're very peaceful and calm compared to some times.