In a surprisingly bipartisan outcome, eight Republicans join Democrats to end the Clinton-era policy that bans gay members of the military from serving openly.

Reporting from Washington — In a landmark vote that for some echoed the nation's greatest civil rights struggles, the Senate on Saturday moved resolutely to abolish the Pentagon's "don't ask, don't tell" policy, which for 17 years has forced gay and lesbian members of the armed forces to keep their sexual orientation hidden.

The 65-31 vote, which came after a charged and sometimes vitriolic debate, was surprisingly bipartisan. Eight Republicans joined Democrats in voting to repeal the Clinton-era policy.

"It is time to recognize that sacrifice, valor and integrity are no more defined by sexual orientation than they are by race or gender, religion or creed," President Obama said Saturday. "It is time to allow gay and lesbian Americans to serve their country openly."

"Our government has sent a powerful message that discrimination, on any level, should not be tolerated," said Joe Solmonese, president of Human Rights Campaign, which fought for years against the ban.

Some conservatives, on the other hand, were deeply unhappy. "The American military exists for only one purpose — to fight and win wars. Yet it has now been hijacked and turned into a tool for imposing on the country a radical social agenda," said Tony Perkins, president of Family Research Council.

The drive toward repeal represented a significant — and somewhat unforeseen — political victory for Obama and Democrats on Capitol Hill, who have struggled to advance their agenda during the final weeks of Congress. Days earlier, it had appeared that partisan squabbling would scuttle the repeal effort as it did the Dream Act, a priority of immigration reform advocates that failed to overcome a Senate filibuster Saturday.

But once the House detached the repeal provision from a Pentagon spending bill and passed a new version of the legislation earlier in the week, gay rights advocates felt that the timing, as well as history, was finally on their side.

Momentum had begun to build anew after testimony earlier in the month by Adm. Michael G. Mullen, chairman of the Joint Chiefs of Staff, and Defense Secretary Robert M. Gates, both of whom again called for an end to the discriminatory policy, citing a Pentagon study that said the change would cause little disruption within the ranks of the military.

More than 14,000 members of the armed forces have been discharged since the policy's inception in 1993.

Democratic Sen. Carl Levin of Michigan, chairman of the Senate Armed Services Committee, pointed to Mullen as a key figure in the breakthrough. Earlier this year, Mullen told lawmakers, "We have in place a policy that forces young men and women to lie about who they are in order to defend their fellow citizens."

"It was a matter of integrity," Levin said. "We cannot tell people they cannot be themselves."

Gates and Mullen also warned that if Congress failed to act, the matter could be settled by the federal courts.

But Gates also cautioned Saturday that although Obama is expected to sign the measure next week, repeal will not happen immediately. Under the legislation, the policy may be altered only once new guidelines are put in place that are "consistent with the standards of military readiness, military effectiveness, unit cohesion, and recruiting and retention," he said.

For that reason, repeal advocates such as Aubrey Sarvis, executive director of the Servicemembers Legal Defense Network, sounded a bit wary, even as a long-fought battle appeared all but over. Sarvis called on Gates and the Pentagon to immediately suspend all investigations and discharges of gay and lesbian personnel.

Much of the drama in the Senate occurred early Saturday morning and centered on whether Republicans would be able to filibuster the bill to prevent it from reaching the floor.

GOP senators, led by Sen. John McCain (R-Ariz.), the ranking member of the Armed Services Committee, accused Democrats of pushing the repeal through in the last days of a lame-duck Congress in defiance, McCain said, of the results of November's election, which made Republicans ascendant in the House and increased their numbers in the Senate.

"We are jamming — or trying to jam — major issues through the Senate of the United States because [Democrats] know they can't get it done beginning next January," McCain said.

He and other Republicans seized upon the testimony of Marine Corps Commandant James F. Amos, who earlier this month warned that a repeal of the policy could be a "distraction" to Marines and put them in harm's way.