A sweeping defense bill that sparked a heated debate over the handling of terrorism suspects passed the Senate on Thursday afternoon and is headed to President Obama’s desk after weeks of wrangling that included a veto threat from the White House.

The $662 billion defense authorization bill was approved by the Senate 86 to 13 one day after the White House withdrew its threat to veto the measure over several controversial detainee provisions. The White House said those provisions would have been an infringement on its executive power. The bill overwhelmingly passed the House on Wednesday 283 to 136.

The measure authorizes military funding for the fiscal 2012 at $27 billion less than Obama’s request and $43 billion less than the amount Congress authorized for the fiscal 2011.

The bill underwent last-minute revision Monday after lawmakers met with administration officials to address the White House’s concerns. The revised bill grants greater discretion to the administration over the implementation of the law and gives waiver authority to the president rather than the secretary of defense.

Although Obama has lifted his veto threat, FBI Director Robert S. Mueller III testified at a Senate Judiciary Committee hearing Wednesday that he thinks there is still a lack of clarity about the interplay between military and civilian law enforcement in regard to taking terrorism suspects into custody.

Civil liberties advocates and human rights groups have urged Obama not to sign the measure, arguing that it would allow for the indefinite detention of U.S. citizens. One of the bill’s main proponents, Senate Armed Services Committee Chairman Carl Levin (D-Mich.), flatly rejected those arguments.

“Probably the most discussed provision in the conference report is the provision relative to military detention for foreign al-Qaeda terrorists,” Levin said. “This provision has been written to be doubly sure that there is no interference with civilian interrogations and other law enforcement activities and to ensure that the president has the flexibility he needs to use the most appropriate tools in each case. Those who say that we have written into law a new authority to detain American citizens until the end of hostilities are wrong.”

Some senators who supported the bill continued to be concerned about some of the detainee provisions after Thursday’s vote. Senate Majority Leader Harry M. Reid (D-Nev.), who backed the measure, said in a statement that the bill “is not perfect” and vowed to press the White House to “implement these provisions in ways that enhance our national security and minimize potential negative impacts.”

The senators voting “no” Thursday spanned the ideological spectrum and included Richard J. Durbin (D-Ill.), Jim De­Mint (R-S.C.), Al Franken (D-Minn.), Bernard Sanders (I-Vt.), Tom Coburn (R-Okla.), Rand Paul (R-Ky.).

Included in the new legislation are a series of attempts at foreign policy making. The measure would apply sanctions against the Central Bank of Iran in an effort to pressure Tehran to abandon its nuclear weapons program and would freeze $700 million in U.S. aid to Pakistan. The bill also calls for Defense Secretary Leon E. Panetta to report to Congress on Pakistan’s progress in combating the use of makeshift bombs.

The State Department signaled Thursday that it would go along with the Iran sanctions despite concerns about the possible effect on global oil prices. State Department spokeswoman Victoria Nuland said administration officials were still studying how to structure the new sanctions in a way that maximizes the pressure on Iran while minimizing the pain for the United States and its allies.

“We’re just at the beginning of looking at this,” Nuland told reporters. She said the White House would have to explain the decision to “a whole host of folks, including our friends and allies around the world.”

The Obama administration has been wary of targeting the Iranian Central Bank, which handles money transfers when Iranian oil is sold to foreign countries. Some U.S. economists say the proposed sanctions could seriously impede Iran’s ability to sell oil, potentially leading to shortages and price spikes that could damage Western economies.

On the domestic front, more than 100 special spending provisions that House members had attempted to add to the measure have been stripped. Sen. Claire McCaskill (D-Mo.) released a 16-page study of the bill last week, declaring all 115 amendments “earmarks,” and called for their removal. She proclaimed victory Thursday, saying that for the first time in decades, the defense authorization bill was earmark-free.

Earlier Thursday, House Armed Services Committee Chairman Howard P. “Buck” McKeon (R-Calif.) unveiled legislation that would postpone for one year an across-the-board cut to Pentagon spending.

The defense cuts, set to take effect in January 2013, are part of a $1.2 trillion “sequester” that was triggered by the failure of the bipartisan debt supercommittee last month.

McKeon’s plan would couple a one-year delay of those cuts with an across-the-board 10 percent reduction in the number of all federal employees that would be achieved almost entirely by attrition. At a news conference Thursday, McKeon said his plan would save $127 billion, with $110 billion of that covering what would have been cut in the first year of sequestration.

The White House has said it would veto any attempt to rework the cuts that doesn’t achieve a full $1.2 trillion in deficit savings. McKeon said Thursday that his measure would give the administration “some time to think about this to know what we’re really doing . . . before we decimate our military.”

Staff writers Kimberly Kindy and Walter Pincus contributed to this report.