The votes were a victory for President Barack Obama, who has actively supported ending the policy, and for gay rights groups who have made repealing the ban their top legislative priority this year.
"Lawmakers today stood on the right side of history," said Joe Solmonese, president of Human Rights Campaign, a major gay rights organization.
With passage, House Speaker Nancy Pelosi, D-Calif., said, "We honor the values of our nation and we close the door on a fundamental unfairness."
The drive to end the ban still has a long way to go. The 234-194 House vote was an amendment to a defense spending bill that comes up for a final vote Friday. While the spending bill, which approves more than $700 billion in funds for military operations, enjoys wide support, some lawmakers vowed to vote against it if the "don't ask, don't tell" repeal was included.
"It jeopardizes passage of the entire bill," said Rep. Gene Taylor of Mississippi, a conservative Democrat who opposed it.
The full Senate is expected to take up the defense bill next month, and Republicans are threatening a filibuster if the change in policy toward gays remains in the legislation.
"I think it's really going to be very harmful to the morale and effectiveness of our military," said Sen. John McCain of Arizona, the top Republican on the Armed Services Committee and a leading opponent of the repeal.
In a statement after the House vote, Obama hailed Thursday's congressional action as "important bipartisan steps toward repeal."
"This legislation will help make our armed forces even stronger and more inclusive by allowing gay and lesbian soldiers to serve honestly and with integrity," Obama said.
The Armed Services vote on the measure was 16-12, with one Republican, Susan Collins of Maine, voting for it and one Democrat, Jim Webb of Virginia, opposing it.
In the House, Republicans, who voted overwhelmingly against the amendment, cited the letters of four military service chiefs urging Congress to hold off on legislation until the military gains a full assessment of the effects the repeal might have on military life and readiness.
Defense Secretary Robert Gates, while voicing support for the repeal, also has said he would prefer that Congress wait until the Pentagon conducts a study, due to be finished in December, on the impact of the policy change.
The House and Senate amendments stipulate that the repeal would not become law until after the study is completed and until the president, the defense secretary and the Joint Chiefs of Staff certify that it will not have negative effects on the military's fighting ability.
Several Republicans voiced strong opposition to any change in current policy. "It is very clear that homosexuality is incompatible with military service," Rep. Steve Buyer, R-Ind., said.
The chief sponsor of the amendment, Rep. Patrick Murphy, D-Pa., who served in the Iraq war, said that when he was in Baghdad, "my teams did not care whether a fellow soldier was straight or gay if they could fire their assault rifle or run a convoy down ambush alley and do their job so everyone would come home safely."
House Majority Leader Steny Hoyer, D-Md., said that of the 13,500 who have been discharged under "don't ask, don't tell," more than 1,000 filled critical occupations, such as engineers and interpreters.