The US Senate has voted to allow openly gay soldiers to serve in the military. The change of legislation, on Saturday, would not take immediate effect.
It is expected to be signed into law by President Obama next week, giving him the chance to fulfil a campaign promise and repeal the 17-year policy known as "don't ask, don't tell."
"It is time to recognise that sacrifice, valour and integrity are no more defined by sexual orientation than they are by race or gender, religion or creed," Obama said in a statement.
Under the bill, the president and his top military advisers must first certify that lifting the ban will not hurt troops' ability to fight. After that, the military would undergo a 60-day wait period.
Gays and lesbians in uniform celebrated in San Francisco, as gays would be openly accepted by the US military and could acknowledge their sexual orientation without fear of being kicked out.
Several former members of the armed forces gathered to watch the Senate vote. And cheers erupted when the final tally of the senate vote, 65-31 was announced.
Supporters say the repeal signals a historic civil rights milestone.
For Zoe Dunning, a retired U.S. Navy Commander , Saturday's vote ended a long struggle that included two military discharge hearings after she announced she was gay.
Dunning was eventually allowed to remain in the Navy.
"After 18 years of working on this, I witnessed the end to this destructive policy and these are tears of joy, I've got to tell you," she said.
Many of those who were dismissed due to their sexual orientation have said that they hope to return to service.
Supporters of repeal filled the visitor seats overlooking the Senate floor, ready to protest had the bill failed.
More than 13,500 service members have been dismissed under the 1993 law that forced gay men and women in the military to hide their sexual identity.
Congressional Democrats struggled in the final hours of the post-election session to overcome Republican objections on several legislative priorities before Republicans regain control of the House in January.
In the end, six Republican senators broke with their party on the procedural vote to let the bill move ahead.
They swung behind repeal after a recent Pentagon study concluded that the ban could be lifted without hurting the ability of troops to fight.
Senator Susan Collins, a Republican from Maine, was a key player in wrangling some of her Republican colleagues to vote for the repeal.
"It was a difficult vote for many of them, but in the end, they concluded, as I have concluded, that we should welcome the service of any qualified individual who is willing to put on the uniform of this country," she said, at a news conference following the vote.
Senator Joe Lieberman, Independent, speaking at the same news conference said that, "It was the right thing to do for our military, it was the right thing to do for our country."
Opponents of gays serving openly in the military argued that lifting the ban would undermine order and discipline and harm unit cohesiveness, especially among combat troops.
The legislation gives the Pentagon an undetermined amount of time, to educate service members and prepare for the policy change before it "certifies" repeal.
In a statement issued immediately after the vote, Robert Gates, defence secretary said that he will begin the certification process immediately.
But any change in policy won't come until after careful consultation with military service chiefs and combatant commanders, he said.
In the meantime Gates says the current law and policy will remain in effect.
"Successful implementation will depend upon strong leadership, a clear message and proactive education throughout the force,'' he said.
Admiral Mike Mullen, chairman of the Joint Chiefs of Staff, said he welcomes the change.
"No longer will able men and women who want to serve and sacrifice for their country have to sacrifice their integrity to do so,'' he said.
At least 25 countries allow gays to serve openly in the armed forces, among them Britain, Canada and Israel, according to the Palm Center, a research institute at the University of California, Santa Barbara.
In February, Mullen provided the momentum that Obama needed by telling a packed Senate hearing room that he felt the law was unjust.
As chairman of the Joint Chiefs of Staff, Mullen became the first senior active-duty officer in the military to suggest that gays could serve openly without affecting military effectiveness.
"No matter how I look at the issue,'' Mullen said, "I cannot escape being troubled by the fact that we have in place a policy which forces young men and women to lie about who they are in order to defend their fellow citizens.''
With Mullen's backing, Gates ordered a year-long study on the impact, including a survey of troops and their families.
The study, released on Nov 30, found that two-thirds of service members didn't think changing the law would have much of an effect.
Mullen and Gates counter that the fear of disruption is overblown and could be addressed through training.
They note that the Pentagon's finding that 92 percent of troops who believe they have served with a gay person saw no effect on their units' morale or effectiveness.