The fight against reductions in military retired pay is over — and retirees have emerged victorious.

The Senate voted resoundingly Wednesday to repeal the planned reductions to annual cost-of-living adjustments, or COLAs, in military retirement pay, approving a bill passed Tuesday by the House that will offset the roughly $6 billion the COLA caps would have saved by extending automatic cuts to Medicare funding by one year.

The Senate vote was 95-3.

The measure now goes to President Obama for his signature.

The outlook for repealing the COLA caps had been murky because of differences over how to offset the cost. Many senators had wanted to repeal the cuts with no offset, which most Republicans would not support.

Speaking to talk show radio host Hugh Hewitt before the vote, Sen. Lindsey Graham, R-S.C., described it as a “big win” for the country.

“There is a time when the two [political parties] in America come together. ... Democrats found it hard to explain why you wouldn’t want to pay for this change, because it’s only $6 billion over 10 years. Republicans found it hard to suggest this was fair. The two sides came together,” Graham said.

Not everyone agreed. Sen. Jeff Flake, R-Ariz., a lawmaker known for fiscal conservatism and one of the three who voted “no,” expressed disappointment that his colleagues would even consider repealing the COLA caps.

“How do we convey the seriousness of the budget crisis when, at the first sign of political pressure, we undo a portion of the bill that we passed less than two months ago?” Flake said.

Under the legislation, military retirees and currently serving troops will receive full cost-of-living adjustments on their retirement pay as approved by Congress each year.

The Bipartisan Budget Act, signed into law on Dec. 26, would have reduced annual COLA increases for current retirees and troops by 1 percentage point for all “working age” retirees under 62, starting in late 2015.

While that is no longer the case for currently serving troops and retirees, anyone who enlists or receives a commission as of Jan. 1, 2014, will be subject to the COLA caps if they serve in uniform long enough to qualify for retirement benefits.

Earlier this week, House Republicans had considered tying the COLA cap repeal to broader legislation to suspend the federal debt ceiling. But that plan was abandoned and instead, Republican leaders attached COLA repeal as a rider to an unrelated bill that had already been approved by the Senate.

The measure passed the House by a vote of 326-90.

Those who supported the legislation, including Rep. Julia Brownley, D-Calif., said it undoes changes that should “never have been in the bipartisan budget bill in the first place.”

“As a member of the House Veterans’ Affairs Committee, I immediately introduced legislation to reverse it because we made a sacred promise to our service members,” Brownley said.

“It is imperative that we keep our promise to the members of the armed services who have sacrificed so much for our country,” said Rep. Gus Bilirakis, R-Fla. “Military retirees have bravely served and made enormous personal sacrifices. Our country promised these retirement pensions to military retirees. I am pleased to see that Congress is able to honor that commitment.”

But the legislation drew criticism from Democrats for its proposal to pay for the lost savings — the extension of sequestration cuts to Medicare to 2024 — while many Republicans who voted against it said they could not support unraveling a budget agreement during tight fiscal times.

Rep. Ben Ray Lujan, D-N.M., who co-sponsored separate legislation that would have paid for repeal by closing tax loopholes for offshore companies, said the offset that was approved “pits seniors against military retirees.”

“I support action to restore the full [COLA] for military retirees who have spent a career serving their country, but it’s disappointing that House Republicans offered a bill that cut Medicare to pay for it,” Luján said. “We need a solution that does not pick winners and losers between military retirees and our nation’s seniors.”

Rep. Paul Ryan, R-Wis., architect of the budget agreement, said the COLA repeal undermines the Bipartisan Budget Act and “puts troops at risk” because it undoes needed cuts to military compensation that would provide more funding for equipment, weapons and training.

“Our military leaders — and the math — have been clear. Compensation costs are hollowing out the Pentagon’s budget. They are taking resources away from training and modernization — and putting our troops at risk,” Ryan said.

He added that the budget agreement purposely delayed the change by two years so the Military Compensation and Retirement Modernization Commission that is currently studying the entire array of military compensation programs could make recommendations for reform.

“I’m open to replacing this reform with a better alternative. But I cannot support kicking the can down the road,” Ryan said.

The Senate had been poised to consider its own legislation to repeal the COLA caps, a provision drafted by Sens. Mark Pryor, D-Ark., and Kay Hagan, D-N.C., that cleared a key procedural hurdle Monday, but included no proposal for offsetting the $6 billion in lost savings.

The situation was a hard-fought battle for military and veterans’ organizations as well as active-duty troops, retirees and family members who launched a grassroots effort to undo the COLA caps.

“The Veterans of Foreign Wars ... thanks all our supporters in the House and Senate for taking quick action to repeal the penalty on working-age military retirees,” said VFW Commander William Thien.

But Thien noted the fact that the new legislation does not remove the penalty on future retirees who enter the military after Jan. 1. “It is in that regard the VFW will continue to fight for a full repeal,” he said.

The head of the largest veterans’ service organization, the American Legion, also said Wednesday he has “mixed feelings” about the vote because the reduced COLA still affects future retirees.

“This action still falls short of reversing the COLA cut,” said Daniel Dellinger, the Legion’s national commander. “Again, as in targeting the Department of Defense for sequestration, this legislation places the responsibility for correcting a financial catastrophe — that is, the unruly national debt — almost solely on our service members.”

The other two senators who voted against the repeal legislation were Sens. Tom Carper, D-Del., and Dan Coates, R-Ind.

A previous version of this story listed Sen. Bob Corker, R-Tenn., as having voted no. Corker voted yes.