WASHINGTON (AP) — Count President Barack Obama, the Pentagon and new Speaker Paul Ryan as winners in the hard-fought budget deal between congressional leaders and the White House.

The losers are tea partyers and those with an aversion to budget gimmicks.

The House passed the measure by a margin of 266-167 on Wednesday and sent it to the Senate. A test vote there Friday should clear the way to complete the legislation before Tuesday's deadline for a market-shattering government default. Once the Senate wraps up the bill, it would head to Obama for his signature.

The bill caps a yearlong fight between Republicans, Obama and Democrats over spending.

Some winners and losers:

____

WINNERS

___

OBAMA AND DEMOCRATS

The agreement satisfies demands by Obama for significant new spending above the limits imposed by the 2011 budget law. Obama requested $74 billion above the cap for 2016. The agreement effectively awards $66 billion, evenly divided between defense and domestic spending. Obama and Senate Democrats executed a strategy of stalling on the spending bills to force GOP leaders to negotiate, then got pretty much what they wanted.

___

PENTAGON AND DEFENSE HAWKS

Military leaders and their congressional allies have been frantic, fearing the return of automatic budget cuts that essentially would have frozen the Pentagon's budget. Instead, under the budget deal, the Defense Department will get an extra $33 billion in 2016, a more than 6 percent increase. The Pentagon budget is roughly $523 billion.

___

RYAN

The newly elected speaker criticized the process that produced the agreement — he said it "stinks" — though it mirrored the approach he used two years ago in reaching a similar pact with Democratic Sen. Patty Murray of Washington state. But the deal clears the decks of difficult budget and debt battles and allows Ryan to focus on other issues and try to unite his badly divided GOP team.

___

MEDICARE AND SOCIAL SECURITY

The agreement fixes two major problems for Medicare and Social Security, the critical entitlement programs.

Social Security's disability trust fund is projected to run out of money in late 2016, which would trigger an automatic 19 percent cut in benefits for 11 million disabled workers and their families. The budget deal would add six years to the life of the disability fund by temporarily reallocating a small portion of payroll taxes from Social Security's retirement fund. The deal also includes changes to the disability program to fight fraud and to encourage disabled workers to return to work.

On Medicare, the budget agreement would avert an unprecedented increase in Medicare Part B premiums for about 15 million people due to a complicated formula involving Social Security's annual cost-of-living adjustment. Since there's no COLA in the coming year, about 30 percent of Medicare beneficiaries are on the hook for a premium increase that otherwise would be spread among all. For these people, monthly premiums were projected to increase by about $54 a month, to $159. The budget deal sets their premiums at $123 in 2016.

___

SENATE GOP CLASS OF 2016

The measure takes the threat of a government shutdown and a potential debt crisis off the table for the duration of the 2016 campaign, a big relief to endangered Republican incumbents such as Mark Kirk of Illinois, Kelly Ayotte of New Hampshire, Rob Portman of Ohio, and Ron Johnson of Wisconsin. All are up for re-election in states Obama carried twice, in 2008 and 2012. And by removing the Social Security issue, those incumbents are spared the potential for divisive votes next year.

____

LOSERS

___

TEA PARTY REPUBLICANS

They may have toppled Speaker John Boehner, R-Ohio, but tea party lawmakers and conservatives in the House Freedom Caucus got rolled again by the tag team of Boehner and House Minority Leader Nancy Pelosi, D-Calif. Many tea partyers were defenders of the very spending curbs that the budget deal unravels and they were wholly shut out of the process that produced the agreement.

___

WASHINGTON PURISTS

To the consternation of budget watchdogs and fiscal purists, the deal is laced with budget gimmicks, many of which produce questionable savings. For example, savings from Social Security changes are double-counted. Sales of oil from the Strategic Petroleum Reserve are inflated. An arcane maneuver involving smoothing of premiums paid to the Pension Benefit Guaranty Corp. artificially inflates near-term revenues that are lost in later years.

Since the deal spends money immediately while generating savings over the long term, interest goes up.

____

FARM STATE LAWMAKERS

Farm state lawmakers were upset over $3 billion in cuts to the crop insurance programs. The measure cuts some of the generous government subsidies to crop insurance companies and limit profits for those companies. Farm state lawmakers say the move could force more companies out of the business — several have already left — and leave fewer options for farmers' insurance coverage.

Late Wednesday, leaders of the House Agriculture Committee said the issue would be resolved in the spending bill implementing the budget deal.

____

HOSPITALS

An arcane provision cutting Medicare reimbursements for outpatient procedures provided by hospitals that acquire doctors' practices has upset the hospital lobby. Unlike the crop insurance provisions, this one won't be reversed.