The bill also applies penalties against Iran's central bank in an effort to hamper Tehran's ability to fund its nuclear enrichment program. The Obama administration is looking to soften the impact of those penalties because of concerns that they could lead to a spike in global oil prices or cause economic hardship on U.S. allies that import petroleum from Iran.
In a statement accompanying his signature, the president chastised some lawmakers for what he contended was their attempts to use the bill to restrict the ability of counterterrorism officials to protect the country.
Administration officials said Obama was only signing the measure because Congress made minimally acceptable changes that no longer challenged the president's terrorism-fighting ability.
"Moving forward, my administration will interpret and implement the provisions described below in a manner that best preserves the flexibility on which our safety depends and upholds the values on which this country was founded," Obama said in the signing statement.
Signing statements allow presidents to raise constitutional objections to circumvent Congress' intent. During his campaign for the White House, Obama criticized President George W. Bush's use of signing statements and promised to make his application of the tool more transparent.
Obama's signature caps months of wrangling over how to handle captured terrorist suspects without violating Americans' constitutional rights. The White House initially threatened to veto the legislation but dropped the warning after Congress made last-minute changes.
Among the changes the administration secured was striking a provision that would have eliminated executive branch authority to use civilian courts for trying terrorism cases against foreign nationals.
The new law now requires military custody for any suspect who is a member of al-Qaida or "associated forces" and involved in planning or attempting to carry out an attack on the United States or its coalition partners. The president or a designated subordinate may waive the military custody requirement by certifying to Congress that such a move is in the interest of national security.
The administration also pushed Congress to change a provision that would have denied U.S. citizens suspected of terrorism the right to trial and could have subjected them to indefinite detention. Lawmakers eventually dropped the military custody requirement for U.S. citizens or lawful U.S. residents.
"My administration will not authorize the indefinite military detention without trial of American citizens," Obama said in the signing statement. "Indeed, I believe that doing so would break with our most important traditions and values as a nation."
Despite the changes, officials cited serious concerns that the law will complicate and could harm the investigation of terrorism cases.
For example, FBI Director Robert Mueller has said the measure would inhibit his bureau's ability to persuade suspected terrorists to cooperate immediately and provide critical intelligence. He told Congress it wasn't clear how agents should operate if they arrest someone covered by the military custody requirement but the nearest military facility is hundreds of miles away.
Other officials have said agents and prosecutors should not have to spend their time worrying about citizenship status and whether get a waiver while trying to thwart a terror attack.
The administration also raised concerns about an amendment in the bill that goes after foreign financial institutions that do business with Iran's central bank, barring them from opening or maintaining correspondent operations in the United States. It would apply to foreign central banks only for transactions that involve the sale or purchase of petroleum or petroleum products.
Officials worry that the penalties could lead to higher oil prices, damaging the U.S. economic recovery and hurting allies in Europe and Asia that purchase petroleum from Iran.
The penalties do not go into effect for six months. The president can waive them for national security reasons or if the country with jurisdiction over the foreign financial institution has significantly reduced its purchases of Iran oil.
The State Department has said the U.S. was looking at how to put them in place in a way that maximized the pressure on Iran, but meant minimal disruption to the U.S. and its allies.
In response to the threatened penalties, Iran warned this past week that it may disrupt traffic in the Strait of Hormuz, a vital Persian Gulf waterway. U.S. officials say that while they take all threats from Iran seriously, they view this latest warning as little more than saber rattling because disrupting the waterway would harm Iran's economy.
The $662 billion bill authorizes money for military personnel, weapons systems, the wars in Afghanistan and Iraq and national security programs in the Energy Department for the fiscal year beginning Oct. 1.
The measure also freezes some $700 million in assistance until Pakistan comes up with a strategy to deal with improvised explosive devices.
Obama signed the bill in Hawaii, where he is vacationing with his family.