WASHINGTON -- Congressional negotiators reached a final deal to extend the popular payroll tax cut for the rest of the year, with Republicans agreeing to tack the $100 billion cost onto the deficit and Democrats accepting diminished jobless benefits as well as some drug testing for the unemployed.

The costliest part of the measure extends the current 2 percent payroll tax holiday enjoyed by some 160 million workers through the end of the year, saving the average family about $1,000.

It also prevents a cut in doctor payments under Medicare, and funds extended unemployment benefits, even as it starts to cut their duration from 99 weeks to 73 weeks.

While the payroll tax break is paid for with borrowed money -- a major concession for GOP leaders who had adamantly opposed new deficit spending -- Democrats gave up their traditional stance that emergency unemployment benefits should not be offset with cuts elsewhere. They also agreed to quicker cuts in the duration, and to allow drug-testing of unemployed people who had tested positive before or who were seeking work in certain jobs.

Republicans relented on other restrictions they had hoped to place on people looking for work, including requiring them to enroll in GED programs.

The entire deal nearly collapsed late Wednesday when three Republican senators on a conference committee tasked with finishing the package refused to sign off, and one Democrat -- Maryland Sen. Ben Cardin -- balked at hits to the federal workforce pension plan. It reportedly took a call from President Barack Obama to break the logjam.

Obama also called Rep. Chris Van Hollen, another Maryland Democrat on the committee who was worried about the impact on the many federal workers in his district.

The $52 billion cost of the unemployment extension and Medicare "doc fix" will be funded in part by forcing federal workers to contribute more to their pensions and by auctioning off unused sectors of the broadcast spectrum. Precise estimates of that revenue were being reviewed by the Congressional Budget Office Wednesday night. Federal workers would pay for about $15 billion of the unemployment extension by having their pension contribution raised from 0.8 percent to 1.55 percent. Spectrum auctions would provide about $15 billion, according to preliminary estimates.

To pay for the $22 billion "doc fix," negotiators agreed to cut about $7 billion that goes to hospitals to cover debts. Another $5 billion would be cut from the health care law's prevention fund, created to curb things like childhood diabetes and smoking. The rest comes from altering payment formulas for hospital aid to certain states, cutting some Medicaid assistance to Louisiana that was boosted after Hurricane Katrina and trimming payments to clinical labs.

The negotiations came together relatively quickly after Republicans caved Monday on their insistance that the payroll tax cut be paid for.

Republicans had admitted they lost the fight over payroll taxes before Christmas, when Democrats were able to paint them as protecting the rich at the expense of middle-class workers, since the tax applies only to incomes up to $108,000. Senior members of the GOP admitted as much, soon after House Speaker John Boehner (R-Ohio) gave in, but cast the Democratic position as purely political.

"When you're dealing with people whose only interest is in the next election, you gotta find some way to break the impasse," Sen. John Cornyn (R-Texas) said. "I think everybody understands this is the president's favorite stick to beat opponents with, and I think part of the strategy of the House Republicans is let's get the sharp sticks and the big sticks off the table."

Democrats embraced the deal after negotiations over specific parts of the compromise, especially the drug-testing and the spectrum auctions, seeing it as an overall win.

The spectrum auction was hailed by Sen. Jay Rockefeller (D-W.Va.) because after unemployment is paid for, about $7 billion to $8 billion would be left to build a nationwide emergency communications system, fulfilling the last major recommendation of the 9/11 commission.

"We've made great progress and are very close to a historic milestone -- creation of a new nationwide communications network for our first responders," Rockefeller said while the final touches were being put on the deal.

Lawmakers said they were not sure when the compromise measure would come up for a vote, because were still being translated into legislative language.