Updated

WASHINGTON (AP) — The House on Friday passed a defense bill that paves the way for gays to serve openly in the military for the first time, but advocates on both sides geared up for a fight in the Senate.

Normally, defense bills pass by wider margins than Friday's 229-186 vote, but many Republicans and a few conservative Democrats said they would vote against it because of the gay ban, which was added to the $700 billion bill in a 234-194 vote late Thursday.

House approval of the "don't ask, don't tell" repeal was a 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. The bill would give the Pentagon the rest of the year to study the issue before the repeal would take effect.

Defense Secretary Robert Gates appealed to the military Friday not to be distracted by the political debate over gays in uniform. In an unusual direct address to troops, Gates said he wanted to assure them that their views on the divisive question still matter.

The Senate is expected to take up the defense bill this summer. Supporters likely will need the votes of 60 of the 100 senators to prevent opponents from blocking it.

And while supportive overall, the White House on Thursday issued a veto threat because the House version includes $485 million for an alternative engine for the new F-35 Joint Strike Fighter.

Gates has sought to eliminate the second engine program, saying it is wasteful. Supporters, in addition to protecting jobs in their districts, say that the competition will save money over the life cycle of the $100 billion project.

The second engine would be built by General Electric Co. and Rolls-Royce in Ohio, Indiana and other states. The main F-35 engine is built in Connecticut by Pratt & Whitney, a division of United Technologies Corp.

Sen. Carl Levin, D-Mich., chairman of the Senate Armed Services Committee and a chief backer of changing the law, said at a news conference Friday most senators support ending the gay ban.

"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 filibuster 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 of Maine, voted for it while one Democrat, Jim Webb of Virginia, 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.

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. The military would also have to first change its rules to comply with the law.