President Obama exercised his veto power Thursday for just the fifth time in his presidency, rejecting a defense authorization bill because of the way it would sidestep budget limitations for the military and because it would restrict the transfer of detainees being held at Guantanamo Bay.

The White House said that the National Defense Authorization Act (NDAA) would tap an overseas contingency operations account designed for emergencies and war costs and use it as a “slush fund” to avoid budget restrictions. Those restrictions — known as sequestration — would impose offsetting across-the-board cuts if spending passed certain levels.

“The president believes that the men and women who serve in our armed forces deserve adequate and responsible funding, not through a gimmick or not through a slush fund but one that would — could withstand scrutiny,” White House spokesman Eric Schultz said.

The veto is a shot across the bow of Congress, which differs with Obama over the outlines of a budget for fiscal 2016. And Obama made an extra point by publicly signing the veto statement before a pool of White House press. The fiscal year ended Oct. 1, and a continuing resolution will temporarily keep the government open through Dec. 11.

Of Obama’s other four vetoes, two were made to block Congress from approving the Keystone XL crude-oil pipeline. One blocked Congress from changing a National Labor Relations Board rule on representation case procedures, and one put aside a measure about the recognition of notarization from one state to another.

The president wants spending limits raised for both non-defense and defense discretionary spending, but most Republicans want to lift limits on defense spending but not on non-defense spending. Obama would raise each category about $38 billion.

“The President has been very clear about the core principle that he will not support a budget that locks in sequestration, and he will not fix defense without fixing non-defense spending,” the Office of Management and Budget said when the bill was first proposed.

“It’s all about the budget,” said Gordon Adams, a defense budget expert and professor emeritus at American University. “The president decided some time ago to take the defense bill and the defense budget hostage, for good reason. The principle is spending-increase equality.”

Congressional Republicans and the White House all claimed to have the best interests of American troops in mind.

“Today the president demonstrated he is willing to put politics ahead of the security of our nation by vetoing this bipartisan bill,” Sen. John Thune (R-S.D.), chairman of the Senate Republican Conference, said in a statement. “This veto jeopardizes the weapons, vehicles, and aircraft our military needs to protect our country.”

Justin T. Johnson, senior analyst for defense budgeting policy at the Heritage Foundation, said that “at a time of growing threats, Congress and the American people must determine whether it’s appropriate to use the defense bill for domestic budgetary leverage.”

But Schultz said Defense Secretary Ashton B. Carter “has called this bill managerially unsound and unfairly dispiriting to our force.”

Sen. Jack Reed (D-R.I.), the ranking Democrat on the Senate Armed Services Committee, said that “our troops deserve a budget that matches their courage and sacrifice.” He said that “the bill itself contains many needed reforms and improvements. There is a lot we can agree on here, and if we dropped the [contingency spending] charade and got back to honest budgeting, I believe we could pass a stronger NDAA with near-unanimous support.”

When the measure was proposed earlier in the year, the Office of Management and Budget said that tapping contingency funds “risks undermining a mechanism meant to fund incremental costs of overseas conflicts and fails to provide a stable, multi-year budget on which defense planning is based.”

Obama is confident, based on substantial Democratic opposition to the defense spending package, that the House will uphold his veto.

The president hopes that once the veto is upheld, there will be enough GOP defense hawks to bring around conservative members of the Republican caucus who care more about budget discipline. Those conservative House Republicans might not turn away from a budget showdown and possible government closure.

The administration also opposes restrictions on how it deals with detainees at the Guantanamo detention facility in Cuba. Obama has said he wants to shut down the facility by the end of his presidency.

There are 114 prisoners there. So far, 657 have been transferred out and nine have died there, according to the American Civil Liberties Union. “The administration has been slowly transferring prisoners to other countries, but the process has been very slow,” the ACLU said in a statement.

The main stumbling block to completing the plan to close the prison is the question of where to house prisoners who are being tried or are being indefinitely detained.

The Obama administration has said that housing the detainees in Guantanamo is expensive.

“Operating this facility weakens our national security by draining resources, damaging our relationships with key allies and partners, and emboldening violent extremists,” the Office of Management and Budget said.

Anthony D. Romero, executive director of the ACLU, said that “if Guantanamo is ever to be closed, now is the time. And today the president clearly did the right thing by rejecting the bill’s restrictions on transferring Guantanamo prisoners who have been locked up without charge or trial for years on end. He said Obama “needs to take decisive action” and do so “soon, before his legacy is irreparably tarnished by the stain of Guantanamo.”