WASHINGTON — The House endorsed the continued war in Afghanistan on Thursday despite acknowledgment from Republicans and Democrats that the American people are war-weary after more than a decade of conflict.

By a vote of 303-113, lawmakers rejected an amendment that would have swiftly ended combat operations in Afghanistan by limiting funds only to the "safe and orderly withdrawal of U.S. troops and military contractors from Afghanistan."

More than 10 years after the Sept. 11 terrorist attacks, American public support for the overseas conflict has deteriorated. An Associated Press-GfK poll released last week showed that backing for the war has hit a new low and is on par with support for the Vietnam War in the early 1970s. Only 27 percent of Americans say they support the war effort, and 66 percent oppose it, according to the survey.

"The American people are far ahead of Congress," said Rep. Barbara Lee, D-Calif., sponsor of the amendment, who called on Congress to stand squarely with the American people. "It's past time to end the war and bring the troops home."

Opponents of the amendment conceded that the public has grown tired of war, but they argued against a precipitous withdrawal.

"If we leave too early and the Taliban and al-Qaida return, more Americans will suffer," Rep. Mac Thornberry, R-Texas, said.

The vote came as the House considered a $642 billion defense budget for next year, debating more than 140 amendments to the far-reaching legislation. Final passage of the measure was expected Friday.

Rather than a speedy withdrawal from Afghanistan, the spending blueprint calls for keeping a sizable number of U.S. combat troops in the country. The bill cites significant uncertainty in Afghanistan about U.S. military support and says that to reduce the uncertainty and promote stability the president should "maintain a force of at least 68,000 troops through Dec. 31, 2014, unless fewer forces can achieve United States objectives."

The United States currently has 88,000 troops there. President Barack Obama envisions a final withdrawal of U.S. combat troops in 2014. Earlier this month, he signed an agreement with Afghan President Hamid Karzai on the role of America forces in counterterrorism and training of the Afghan military. The president insisted that the U.S. combat role was winding down.

In a series of votes late Thursday, the Republican-controlled House narrowly passed an amendment preventing federal agencies from requiring contractors to sign project labor agreements to secure federal contracts. The agreements require contractors to negotiate with union officials, recognize union wages and generally abide by collective-bargaining agreements. The vote was 211-209.

Clamoring for fiscal austerity, House Republicans backed deficit-cutting legislation last summer that calls for a $487 billion cut in projected defense spending over 10 years. They abandoned that plan in March, embracing a budget that adds billions of dollars for the military while slashing funds for some safety-net programs for the poor.

The $642 billion spending blueprint — $8 billion more than last year's agreement — provides funds for aircraft, ships, weapons, the war in Afghanistan and a 1.7 percent pay raise for military personnel. The House Armed Services Committee, in crafting its version of the budget, snubbed the Pentagon and military leaders on a range of issues, rejecting calls for another round of domestic base closings and increases in monthly health care premiums for working-age military retirees.

Health care costs have skyrocketed for the military, rising from around $19 billion in 2001 to more than $53 billion in recent years. The Pentagon has estimated that the premium hike — ranging from $35 to $140 per month — would save the military more than $12 billion over 10 years. But one of the most powerful constituencies, the network of veterans groups and retired generals, has lobbied lawmakers to prevent any increase.

The House's action on the budget has divided Republicans.

In a statement Thursday, Sen. Bob Corker, R-Tenn., said that if the House is serious about cutting the deficit, it can show its commitment by not passing "a final highway bill, postal bill or any other bill that would violate the Budget Control Act" — last summer's deficit-cutting pact between Obama and Congress.

Republicans used the House bill to make an election-year argument that they're stronger on defense than the president.

They backed construction of a missile defense site on the East Coast that the chairman of the Joint Chiefs of Staff says is unnecessary, saved aircraft and ships slated for cost-saving retirement, and slowed planned reductions in the Army and Marine Corps. They added millions of dollars for nuclear weapons and restricted the president's ability to reduce the nuclear stockpile under a treaty with Russia that the Senate ratified in December 2010.

Still fighting Obama's long-settled decision to allow gays to serve openly in the military, the bill would bar same-sex marriages on military installations.

"Welcome to the world of manufactured crisis," House Minority Leader Nancy Pelosi, D-Calif., told reporters in criticizing the provision as unnecessary.

The political challenges embodied in the bill are unlikely to survive. The White House has threatened to veto the legislation, citing a long list of objections. Defense Secretary Leon Panetta has slammed the bill and lawmakers for protecting their pet projects. The Democratic-controlled Senate Armed Services Committee is expected to jettison many of the provisions in its version of the budget. The committee meets next week to write its bill.

The GOP effort to make Obama's national security record an issue in the campaign has gotten little traction. Opinion surveys show Americans give the president high marks on defense after the killing of Osama bin Laden, repeated drone attacks against suspected terrorists and a weakened al-Qaida, and an end to the Iraq war.

The House planned to debate the remaining amendments throughout the night Thursday, including one that would end the indefinite detention of terrorist suspects, even American citizens, captured on U.S. soil.

The issue has proved highly divisive for both parties.

"The president right now has the authority to go outside and lock somebody up indefinitely," said Rep. Adam Smith of Washington state, the top Democrat on the House Armed Services Committee. "It's an extraordinary amount of power to give the executive branch."

Smith and several tea party Republicans back an amendment that would bar indefinite detention without charge or trial of suspected terrorists and roll back the military custody requirement. Last year, Congress passed and Obama reluctantly signed a defense bill that included the provision allowing indefinite detention.

Thornberry, the Texas Republican, argued that the amendment would give terror suspects full constitutional rights.

"As soon as a member of al-Qaida sets foot on U.S. soil, they hear you have the right to remain silent," he said during debate.

Smith pointed out that the Constitution grants all persons due process. "Your beef is with James Madison," Smith said.

On Tuesday, a federal judge in New York struck down as unconstitutional the portion of the defense law that gives the government broad powers to regulate the detention, interrogation and prosecution of suspected terrorists.