Washington (CNN) -- The Senate voted 65-31 on Saturday to repeal the "don't ask, don't tell" law, which bans openly gay people from serving in the armed forces.
The measure now goes to President Obama to sign. The House of Representatives passed the measure 250-175 on Wednesday.
Obama and the Pentagon must certify that repealing the 1993 law will not adversely affect the armed services.
Obama earlier Saturday called an earlier procedural vote advancing the repeal toward a final vote a "historic step toward ending the controversial policy."
"It is time to close this chapter in our history," Obama said.
Earlier Saturday, a bill that would have offered a path to citizenship to some illegal immigrants who entered the United States as children failed a procedural vote.
Known formally as the Development, Relief and Education for Alien Minors Act, the DREAM Act fell five votes short of the 60 needed to be considered for final passage.
Obama said Saturday that the failure of the Senate to move the DREAM Act forward was "incredibly disappointing."
Republican Sens. Susan Collins and Olympia Snowe of Maine, Mark Kirk of Illinois, Lisa Murkowski of Alaska, George Voinovich of Ohio, and Scott Brown of Massachusetts voted to advance the "don't ask, don't tell" repeal toward a final vote.
Sen. Joe Lieberman of Connecticut, who co-sponsored the legislation that would repeal the policy, said Friday that Republican senators supporting the bill had "shown courage."
Lieberman said that the bill's co-sponsors had worked closely with the Defense Department in crafting its language.
But Pentagon officials are warning gay and lesbian soldiers that the current law will temporarily remain in place if the bill passes as they review the legal technicalities of the repeal.
A guidance memo would be sent to military personnel informing them of the change, which would remain in effect for at least 60 days after it is signed into law, Pentagon spokesman Col. David Lapan said.
Conservative Republicans have argued that, among other things, a repeal would place an unreasonable burden on the military at a time when it is facing severe strains in Afghanistan and elsewhere.
The Senate is convening this weekend to finish up matters at hand before the lame-duck congressional session ends.
The DREAM Act would have offered legal standing to immigrants who entered the United States illegally as children under the age of 16 and have lived in the country for at least five years.
Other requirements included graduating from high school or obtaining a GED diploma and demonstrating "good moral character."
Even then, only a six-year conditional status would be awarded. Before moving to the next phase, the students would need to meet additional requirements -- attending college or serving in the military for at least two years, and passing criminal background checks.