The US Senate on Friday approved a $633 billion defense spending bill for next year that tightens penalties on Iran, funds the war in Afghanistan and boosts security at US missions worldwide.

The legislation passed 81-14 despite furious opposition from Republican Senator Rand Paul, who criticized removal of an amendment that would have provided Americans with protection against indefinite military detention.

Despite a raging partisan row in Washington over how to resolve a year-end fiscal crisis, the compromise bill sailed through the House of Representatives on Thursday and now goes to President Barack Obama's desk.

In addition to covering standard national security expenses like shipbuilding, it provides a 1.7-percent pay raise for men and women in uniform, authorizes the Pentagon to pay for abortions in cases of rape and incest and lifts a ban on same-sex marriage ceremonies on military bases.

The National Defense Authorization Act for fiscal year 2013 was hammered out by House and Senate conferees this month after each chamber voted to approve separate versions of the bill.

They compromised on overall spending figures, settling on $527.4 billion for the base Pentagon budget; $88.5 billion for overseas contingency operations including the war in Afghanistan; and $17.8 billion for national security programs in the Energy Department and Defense Nuclear Facilities Safety Board.

The White House last month said Obama could veto the act out of concern for the restrictions on his handling of Guantanamo detainees, but Senate Armed Services Committee chairman Carl Levin said this week he did not expect a veto.

The bill extended for one year the restriction on use of US funds to transfer Guantanamo inmates to other countries, a limitation critics say marks a setback for Obama's efforts to close the detention center.

Paul said it was a "travesty of justice" that an amendment designed to limit the president's power to indefinitely detain US citizens as terror suspects was stripped from the final bill.

"It's a shame to scrap the very rights that make us exceptional as a people," Paul said, referring to the rights to a trial for anyone held in the United States.

"Am I the only one uncomfortable applying the law of war to American citizens accused of crimes in the United States?" he asked.

Levin assured that nothing in existing law denied the right to a fair trial, adding that "the language in this conference report reflects my view that Congress did not restrict anyone's constitutional rights."

Rights groups had expressed concern with the amendment because it referred specifically to US nationals and legal residents, leaving open the possibility that under the rule the military might be used to detain illegal immigrants.

In the wake of this year's deadly attack on the US mission in Libya that killed the US ambassador and three other Americans, the bill authorized an increase of 1,000 Marines to protect US diplomatic missions.

"The tragic events in Benghazi on September 11th demonstrate that the security environment facing our diplomatic corps is as dangerous as ever," said Senator John McCain.

"This provision will provide for the end-strength and resources necessary to support an increase in Marine Corps security at locations identified by the secretary of state to be at risk of terrorist attack."

The bill also authorizes $9.8 billion for missile defense, including funds for a Pentagon feasibility study on three possible missile defense sites on the US East Coast.