If it clears the Senate, the repeal would become law only after a Pentagon study on its impact and after the president and military leaders certify that the policy change will not affect the military's fighting ability.
The House voted 229-186 to pass a defense bill approving more than $700 billion for military programs and containing an amendment overturning the 1993 law allowing gays to serve in the military only if they hide their sexual orientation.
The defense bill, which normally passes by wide margins, was closer this year because many Republicans and a few conservative Democrats said they would vote against it if it contained the repeal of the gay ban. The amendment was approved 234-194 late Thursday after dominating the debate during the day.
House approval of the "don't ask, don't tell" repeal was a major victory for President Barack Obama, who has pledged to change the policy, and for gay rights groups, who have made it their top priority this year.
Defense Secretary Robert Gates appealed to the military Friday not to be distracted by the political debate over gays in uniform. In, Gates said he wanted to assure them that their views on the divisive question still matter.
Gates has said he supports the repeal but wanted Congress not to legislate before the military conducts an in-house survey of how the change would affect military life and operations. He was overruled by the administration, which was under pressure from gay rights groups to take up the issue this year, when Democrats still hold a secure majority in Congress.
Sen. Carl Levin, a Democrat and chairman of the Senate Armed Services Committee and a chief backer of changing the law, said he hoped to get the defense bill to the floor before Congress leaves for its summer recess at the end of July. At a news conference Friday, he expressed confidence the ban repeal would stay in the bill.
"I believe a majority of the Senate, just like a majority of the country ... favor changing this policy," he said. "It is a discriminatory policy."
He predicted that it would be hard for opponents to delay the defense bill over the gay rights issue because "there's so much in here for our troops." That includes money for security projects in Afghanistan and Pakistan, anti-terrorism programs, billions for new ships, planes and mine-resistant ambush protected vehicles and money for ballistic missile defense. The House bill has a 1.9 percent pay raise for military personnel; the Senate bill 1.4 percent.
Levin's committee on Thursday approved an amendment repealing "don't ask, don't tell" on a 16-12 vote. One Republican, Susan Collins, voted for it while one Democrat, Jim Webb, a Vietnam veteran, opposed it.
Webb said he agreed with Gates and the chiefs of the four military services, who have urged Congress to put off votes until after the military review is completed in December.