Washington (CNN) -- The Senate on Saturday approved a compromise spending bill to keep the government funded for the rest of the fiscal year -- a day after the bill won approval from the House of Representatives.
The bill now heads to President Barack Obama for his signature. Obama signed a continuing resolution passed by the House to keep the government funded through next week while the bill's details are finalized.
The almost $1 trillion measure passed on a 296-121 vote in the House on Friday, before heading to the Senate where it passed 67-32-- averting a partial government shutdown as a deadline loomed at midnight Friday.
A one-day continuing resolution was passed by the Senate on Friday and signed by Obama to keep the government funded through Saturday's vote.
Senators on Saturday also voted to extend the payroll tax cut by two months, after both sides were unable to reach a comprehensive agreement to extend the payroll tax cut and unemployment benefits for a full year.
The two major pieces of legislation were linked this week in political maneuvering involving the White House and Senate leaders.
Congressional negotiators signed off on the government appropriations plan Thursday night. The giant spending package appropriates money for the rest of fiscal year 2012, which ends September 30, at levels agreed to in the debt-ceiling agreement in August.
Obama and Democrats have pushed for the separate measure that would prevent the payroll tax cut enacted last year from expiring at the end of this month.
A Democratic effort to delay action on the spending plan -- which was agreed to by a bipartisan conference committee -- until resolution of the payroll tax cut issue fell apart in talks between party leaders that began Wednesday night.
With House approval of the spending plan, the onus of legislative action fell on the Senate, where a deep partisan divide had stalled progress on the payroll tax-cut measure until negotiations began in earnest Thursday.
The Senate talks involve extending the payroll tax cut and other provisions that expire at the end of the year, including an extension of unemployment benefits and an increase in payments to doctors who provide Medicare services.
Democrats want these programs to be extended through 2012, but they had floated the idea of a fallback two-month extension to ensure there will be no negative impact on Americans if Congress fails to reach a broader deal.
A Senate Democratic leadership aide said the two-month extension would clear the way for further negotiations on a larger deal.
But House Speaker John Boehner said Friday that any attempt for a short-term extension of the payroll tax cut and unemployment benefits would get altered in the House, in particular by adding a controversial provision to speed government approval of the Keystone XL oil pipeline from Canada.
According to congressional sources, and confirmed by Republican Sen. John Thune of South Dakota, the two-month plan proposed by Senate negotiators Friday night included the oil pipeline provision. It also would extend the lower payroll tax rate, unemployment benefits and the increased payments to Medicare doctors.
The Obama administration has delayed until 2013 a decision on the pipeline that would transport oil from Canada's tar sands production facilities in northern Alberta to refineries on the Gulf Coast of Texas.
The delay followed complaints by environmentalists and Nebraska officials that the pipeline route could threaten that state's Sandhills region and vital Ogallala aquifer. Alternate routes are being considered, and Nebraska officials as well as the pipeline company, TransCanada, acknowledge that the process of approving a final route will last into the second half of 2012.
Republicans, who traditionally back the oil industry, accuse Obama of delaying the issue until after his re-election bid next year for political reasons.
In the House, they added the provision to require a decision on the Keystone project within 60 days, arguing it would create jobs and reduce U.S. dependency on oil from the Middle East. The House version lacked Senate support and never came up for a vote.
The State Department, which has final authority to approve the oil pipeline, warned that the shortened deadline for a decision on the pipeline would effectively kill the project because there would be insufficient time to assess the route alteration.
The legislative maneuvering was a last-gasp bid to end weeks of political wrangling that threatened a partial government shutdown and raised public frustration with Congress even further.
A poll released Thursday by the Pew Research Center for the People and the Press showed public discontent with Congress at record levels, with two-thirds of voters saying most lawmakers should be voted out of office next year.
CNN's Ted Barrett and Kate Bolduan contributed to this report.