The Senate approved the $143 billion measure on a bipartisan 60-36 vote minutes after the House approved it by a sweeping 293-132 vote. Obama is expected to sign it shortly after returning from a West Coast fundraising swing.
Under the bill, workers would continue to receive a 2 percentage point increase in their paychecks, and people out of work for more than six months would keep jobless benefits averaging about $300 a week, steps that Obama says will help support the fragile recovery from the worst economic downturn since the Great Depression.
It would also head off a steep cut in reimbursements for physicians who treat Medicare patients.
The tax cuts, jobless coverage and higher doctors' payments would all continue through 2012.
Passage of the legislation hands Obama a victory over objections from many Republicans who oppose it but were eager to wipe the issue from the election-year agenda.
It also clears away a political headache for House Republicans, who blocked a two-month extension of the tax cut and jobless coverage in late December, only to retreat quickly under a buzz saw of opposition from conservative and GOP leaders from around the country.
With that history, Republicans seemed ready to get the fight behind them and change the subject for the rest of this election year.
"We're dumb, but we're not stupid," McCain told reporters after he voted. "We did not want to repeat the debacle of last December. It's not that complicated."
Opposition was particularly strong in the Senate, where Republicans opposed the measure by a 2-1 margin. In the House, however, a solid majority of Republicans backed the measure despite reservations about its $89 billion impact on the budget deficit over the coming decade.
And Republicans said the final deal, significantly changed from a tea party-backed measure that passed in December, was the best Republicans could get.
"We don't control Washington. Democrats still control Washington -- they control the Senate, and they control the White House," said Rep. Dave Camp, R-Mich., the top House negotiator on the measure. "A divided government must still govern." Camp cited stricter job search requirements for people receiving unemployment benefits and other reforms to the program as wins for conservatives.
But many GOP lawmakers were upset that the measure would add to the federal deficit and doubted that it would do much to boost the economy. Another concern was that it cuts a payroll tax that's dedicated to paying Social Security benefits. Deficit spending would make up for the lost revenue, but some lawmakers fear it would chip away at the program.
"I cannot and I will not support legislation that extends the payroll tax holiday without paying for it," said Rep. Phil Gingrey, R-Ga. "This will add $100 billion to the deficit and it will create an even greater shortfall within the Social Security trust fund that already has over $100 billion shortfall just in the last two years."
And the No. 2 Democrat in the House, Steny Hoyer of Maryland, excoriated the measure for cutting the retirement benefits of new federal hires.
"The only individuals paying for this bill out of 315 million Americans are the two million civilian workers who work for us, who work for all of us, day after day, week after week, month after month," Hoyer said.
Extending the 2 percentage point cut in the 6.2 percent Social Security payroll tax would save around $80 monthly for someone earning $50,000 a year and give a maximum cut of $2,200 to high-end earners.
The reduction in the Social Security payroll tax, which is deducted from workers' paychecks, would cost $93 billion through 2022. In a sudden concession this week that made bipartisan agreement possible, House Republicans dropped their demand that the tax cut be paid for with spending reductions.
In a GOP win, coverage for the long-term unemployed would be cut from the current maximum of 99 weeks to a ceiling of 73 weeks by this fall in states with the worst job markets, with most topping out at 63 weeks.
Of the $30 billion cost of the extended unemployment benefits, half would be paid for by government sales of parts of the nation's broadcast airwaves, half by requiring federal workers hired after this year to contribute an additional 2.3 percent of their pay for their pensions, up from the current 0.8 percent.
That increase also would apply to members of Congress, but only to those who begin service as of next January -- exempting every current lawmaker.
The bill also would prevent a 27 percent cut in federal payments to doctors who treat Medicare patients, a reduction that threatened to make it harder for seniors to find physicians.
That would cost about $18 billion. It would be paid for by trimming Medicare reimbursements to health care providers to cover unpaid medical bills, cutting payments to hospitals that treat large numbers of poor patients and cutting a fund created in Obama's health care overhaul for preventing diseases caused by smoking and obesity.
A House-approved measure letting states test unemployment benefit applicants for drug testing was pared back, permitting the tests only for people who lost their jobs due to drug use or whose new jobs would require such tests.
Those seeking unemployment coverage would have to show they are actively seeking work, but another GOP-backed provision forcing them to pursue high school equivalency diplomas was abandoned.
Associated Press writer Andrew Taylor contributed to this report.