WASHINGTON - The Senate acted Saturday to end the Pentagon's "don't ask, don't tell" policy on gays and lesbians in the military, as President Obama declared "it is time to close this chapter in our history."

The 65-31 vote, which sends the bill to Obama for his signature, not only was a historic triumph for gay rights, but it also sets the stage for gays to serve openly in the military for the first time.

It was lauded as "one of those moments in our history when we stepped up and squared our policies with the values this nation was founded on," said Senate Majority Leader Harry Reid (D., Nev.).

Obama, who is expected to sign the measure this week, left no doubt he will push to implement the new policy.

"By ending 'don't ask, don't tell,' no longer will our nation be denied the service of thousands of patriotic Americans forced to leave the military, despite years of exemplary performance, because they happen to be gay," he said. "And no longer will many thousands more be asked to live a lie in order to serve the country they love."

Obama's signature will not mean instant repeal, but Defense Secretary Robert M. Gates pledged Saturday to move quickly.

"Once this legislation is signed into law by the president, the Department of Defense will immediately proceed with the planning necessary to carry out this change carefully and methodically, but purposefully," he said after the vote.

The effort will be led by Clifford Stanley, undersecretary of defense for personnel and readiness and himself a retired Marine Corps major general.

Under the legislation, Gates explained, repeal will take effect once the president, the secretary of defense, and the chairman of the Joint Chiefs of Staff certify that implementation of the new policies and regulations written by the department "is consistent with the standards of military readiness, military effectiveness, unit cohesion, and recruiting and retention of the Armed Forces."

The Pentagon has said it could take up to a year to implement the new policy.

The House passed the bill Wednesday, and Saturday, Senate passage was smoothed by a 63-33 vote earlier in the day to limit debate.

On the final vote, eight Republicans - Richard Burr of North Carolina, Mark Kirk of Illinois, Lisa Murkowski of Alaska, George Voinovich of Ohio, Scott Brown of Massachusetts, John Ensign of Nevada, and Olympia Snowe and Susan Collins of Maine - joined 55 Democrats and two independents in backing the measure.

The Defense Department earlier this month reported that in an eight-month study of more than 115,000 military personnel, 70 percent said that ending the ban on gays serving openly would have a positive or neutral effect.

But combat-unit personnel were more skeptical, as 58 percent of Marines and 48 percent of Army respondents said that ending the ban would have negative consequences. A substantial minority also said repeal could affect morale, training, and whether they would stay in the military. Marines voiced the loudest opposition.

Opponents of the repeal said the survey illustrates why the policy should not be overturned.

"There will be high fives all over the liberal bastions of America, and we'll see [on] the talk shows tomorrow, a bunch of people talking about how great it is," said Sen. John McCain (R., Ariz.). "Most of them have never served in the military or maybe not even known someone in the military."

And military personnel are contacting him and saying of "don't ask, don't tell," "it isn't broke and don't fix it," he said.

Other skeptical senators contended that the vote, which interrupted a debate over a nuclear-arms treaty with Russia, was little more than a political maneuver.

"This is a political issue, an issue to accommodate a group of supporters of the other side of the aisle," said Sen. Bob Corker (R., Tenn.). "I'm not saying this isn't a legitimate issue, but it is political."

Supporters argued that ending the ban was long overdue.

Steven Goldstein, chair of the gay-rights group Garden State Equality, said in a statement: "We will remember today's repeal in the same way millions will always remember the great civil rights landmarks of the 1950s and 1960s - as an enduring milestone that reflects the promise of our nation and the very best of whom each of us in America can be."

After the vote, Mullen said: "It is the right thing to do. No longer will able men and women who want to serve and sacrifice for their country have to sacrifice their integrity to do so. We will be a better military as a result."

"This is the only law in America today that mandates someone be fired just because of who they are," said former Air Force Maj. Mike Almy, who was discharged under the old policy.

Repeal backers got strong support from many senators.

"If you care about national security, if you care about our military readiness, you will repeal this corrosive policy," Sen. Kirsten Gillibrand (D., N.Y.) said during the spirited Senate debate.

Senate backers were concerned that if they did not act, courts would end up setting the policy, a fear also voiced by Gates.

A series of conflicting court rulings made it difficult, if not impossible, for the military to keep up and properly abide by the law. In October, a California appeals court ruled to reinstate "don't ask, don't tell" after a federal district court judge found it unconstitutional and issued a worldwide stay of the law a week earlier.

In response to the legal bickering, Gates issued an order saying only top civilian Pentagon leaders could force a service member out of the military under "don't ask, don't tell." Since that change, no one has been discharged from the military under the policy.

But supporters of repeal wanted more legal backup.

"In the end, the Constitution charges the Congress with setting military policy and the executive branch with implementing it," said Kirk, the Illinois senator. "As a 21-year Navy Reserve officer, I believe it is important for military leaders, not federal judges, to run our armed forces."