Before President Barack Obama finally signed it into law the day after Christmas, a defense-authorization measure bogged down for months in Congress over disputes about sexual assault prosecutions, terror detainees, Iran sanctions, surveillance of Americans and other hot-button issues.

But beyond the headlines, camera glare and Twitter buzz, the legislation reveals a complex struggle between the president and Congress over the direction of American military policy for years to come.

Away from the spotlight, White House and congressional aides haggled over a broad range of significant issues, from base closings, nuclear arms development and force realignment in the Pacific to security clearance rules and pay caps for defense contractors.

The differences are spread across reams of paper and buried in the small print. The bill in its final form was 1,105 pages. An accompanying legislative report that explained its intricacies and translated its legalese into normal English filled an additional 532 pages.

The struggle between the executive and legislative branches cuts across Washington’s usual party lines: Republicans backed Obama on some issues and Democrats pushed to increase congressional oversight on others.

In some ways the struggle has historical roots in the Founding Fathers’ decision to make the president commander in chief, but to give Congress the power of the purse to wage war.

In other ways, the struggle reflects how lawmakers and their constituents have become wary of war and leery of expanding presidential prerogatives after a dozen years of conflict in Afghanistan and Iraq, with unclear outcomes in both countries.

“The president would like unfettered authority to manage the military, but Congress sees that as an invitation to abuse,” said Loren Thompson, a defense analyst with the Lexington Institute, a nonprofit public-policy think tank in Arlington, Va. “So (lawmakers) insist on reports, regulations and restraints.”

In passing both chambers of Congress by wide margins, the measure gives Obama broad bipartisan support on some of his key defense policies, but it expresses bipartisan opposition to others.

“Unlike a lot of other bills, you often find that divisions on the Defense Authorization Act don’t fall neatly into partisan categories,” said Claude Chafin, an aide to Rep. Howard “Buck” McKeon, a California Republican who helped negotiate the measure’s final version as the chairman of the House Armed Services Committee. “Often there are honest disagreements about the best way to move forward on a particular policy or to resolve a particular issue.”

There’s a mixed result in the newly enacted law for Obama’s desire to close the U.S. prison at Guantanamo Bay, Cuba. The defense bill continues the congressional prohibition on transferring terrorism suspects from Guantanamo to prisons in the United States, but it gives the president more flexibility to move some of them to other countries.

In a detailed “Statement of Administration Policy” issued in mid-November by the White House Office of Management and Budget, Obama objected to 17 specific clauses in an earlier version of the defense bill.

“A number of the provisions … raise additional constitutional concerns, including interference with the president’s authority as commander in chief to direct deployment and use of the armed forces and exclusive authorities related to international negotiations,” the statement said.

And that was in response to the defense measure crafted by a fellow Democrat — Sen. Carl Levin of Michigan, the chairman of the Senate Armed Services Committee.

After weeks of negotiations, the Senate Democratic bill was fused with the House of Representatives Republican measure crafted by McKeon. Congress passed that legislation Dec. 19 and Obama signed it into law Dec. 26 — even though most of the objectionable clauses remained in the final measure.

“This legislation continues our effort to rebuild a military that has been tested by a decade at war,” McKeon said. “It upholds the unwavering tradition of congressional oversight, while providing support to the war-fighter and value to the taxpayer.”

(EDITORS: BEGIN OPTIONAL TRIM)

By then, the rhetoric coming from the White House was more conciliatory as Obama decided that an imperfect measure was better than no measure at all.

“Although the bill includes a number of provisions that restrict or limit the Defense Department’s ability to align military capabilities and force structure with the president’s strategy and (to) implement certain efficiencies, overall the administration is pleased with the modifications and improvements contained in the bill,” White House press secretary Jay Carney said.

(END OPTIONAL TRIM)

Two of the clauses that Obama specifically cited as interfering with his constitutional role as commander in chief remained in the final measure. One of them spells out a strategy to prevent the spread of weapons of mass destruction in the Middle East and North Africa.

(EDITORS: BEGIN OPTIONAL TRIM)

Starting on page 656 of the legislation, there are has five pages of instructions for how the secretary of defense, in consultation with the secretaries of state and energy, is to implement the strategy. This includes providing cost estimates and assessing other countries’ efforts.

The provision sets a deadline of March 31 for the Pentagon chief to submit a report on the nonproliferation strategy to four House and Senate committees.

(END OPTIONAL TRIM)

Another clause requires a similarly detailed plan for tightening controls on how the government conducts security background checks and gives security clearances to federal employees and contractors.

(EDITORS: BEGIN OPTIONAL TRIM)

Lawmakers ignored Obama’s protest that the requirement conflicted with an ongoing review of security procedures he ordered in the wake of the Sept. 16 shooting that killed 12 people at the Washington Navy Yard, carried out by a contract employee with a security clearance and access to classified areas.

(END OPTIONAL TRIM)

Obama also objected to a provision that requires the Afghan government to tap future oil revenues to reimburse the United States for foreign aid it used for oil exploration and mining.

“It is not the policy of the U.S. government to seek reimbursement for economic assistance programs,” the administration wrote. “In addition to contradicting long-standing precedent, this provision could harm U.S.-led efforts to build a sustainable Afghan economy and secure a long-term revenue source for the Afghan central government.”

The protest was to no avail; the clause stayed in place.

(EDITORS: STORY CAN END HERE)

(EDITORS: BEGIN OPTIONAL TRIM)

In another controversy, Congress placed cost limits on a planned movement of 9,000 Marines from the U.S. military base in Okinawa, Japan, to bases in the U.S. territory of Guam.

Lawmakers turned a deaf ear to Obama’s objection that the restrictions impede the broader “Asia-Pacific rebalance” he’s trying to implement, which would shift some U.S. military focus from the Middle East toward China and other emerging powers.

“These actions would raise questions among (Pacific) regional states about the reliability of the United States’ security commitments to allies in the region,” the administration protested.

(END OPTIONAL TRIM)

Some disputes stem from a clash between Obama’s national perspective as president and lawmakers’ local perspectives tied to their states and districts.

Congress rejected the president’s request to authorize a new round of military base closings, even as the Pentagon budget shrinks with U.S. involvement over in Iraq and winding down in Afghanistan.

Lawmakers also threw sand on Obama’s initiative to develop a new type of “interoperable” nuclear warhead that can fit on the different missiles launched from air, sea and land.

Instead, Congress wants the Pentagon and the National Nuclear Security Administration to compare the costs of developing that warhead with maintaining the current warheads.

Those warheads are attached to missiles in planes, ships and underground launchpads spread among various bases and military units in congressional districts across the country.

Congress declined to authorize continued funding of five post-9/11 websites that disseminate “public diplomacy” — State Department lingo for U.S.-style propaganda — in southeast Europe, Turkey, Northern Africa, Iraq and Central Asia.

When Obama protested, lawmakers authorized spending $2 million, but with directions to use the funds to shut the websites down.