U.S. President Barack Obama has signed a landmark law, reversing a longstanding policy that forced homosexuals serving in the American military to conceal their sexual orientation.

"Valor and sacrifice are no more limited by sexual orientation than they are by race, or by gender, or by religion or by creed," Obama said in a speech to a capacity crowd gathered in a large auditorium at the Interior Department in Washington Wednesday.

"That's why I believe it is the right thing to do for our military. That's why I believe it is the right thing to do period," he added.

While it will take some time for the repeal of the U.S. military's infamous 'don't ask, don't tell' policy to take effect, the signing nevertheless marks a political victory for the president who made the move one of his campaign pledges.

"No longer will our country be denied the service of thousands of patriotic Americans who were forced to leave the military regardless of their skills, no matter their bravery or zeal, no matter their years of exemplary performance because they happen to be gay," Obama said to rousing applause.

"No longer will tens of thousands of Americans in uniform be asked to live a lie or look over their shoulder in order to serve the country they love."

The law tells American armed services to allow homosexuals to serve openly for the first time, but will only come into effect once implementation plans and guidelines covering everything from troop education to barracks arrangements have been finalized.

Lawmakers will also require assurances that the forces' combat readiness will not be affected, as critics have charged.

In the meantime, the president can revel in achieving a goal he pledged during his 2008 campaign, and reiterated in this year's State of the Union address.

"It's the right thing to do," Obama said at the time.

Since then, he's come under fire for failing to move more quickly. But Obama has argued such a significant policy shift must be carefully planned.

After the Senate voted to approve the bill on Saturday, following earlier action by the House of Representatives, the four military service chiefs made it clear that the changes will still take time.

"The implementation and certification process will not happen immediately," Air Force Chief of Staff Gen. Norton Schwartz wrote in an e-mail to airmen. "Meanwhile, the current law remains in effect. All Air Force members should conduct themselves accordingly."

Once the new regulations are officially certified, implementation will begin 60 days later.

But in his speech Wednesday, Obama made it clear he believes little will change in the meantime for those service men and women who must keep their "secret" a while longer.

"As the first generation to serve openly in our armed forces you will stand for all those who came before you, and you will serve as role models to all who come after," he said, noting the scores of closeted soldiers whose contribution has been historically unrecognized.

"I know you will fulfill this responsibility with integrity and honour, just as you have with every other mission with which you have been charged."

Former Marine Staff Sgt. Eric Alva, an Iraqi war veteran who is openly gay, was invited to stand beside Obama as he signed the bill.

"It was surreal . . . I never thought I'd receive an invitation to stand beside him and watch him sign this bill," he told CTV News Channel Wednesday afternoon.

"I am proud to stand up there and in a way, represent the men and women who served under this policy."

Alva said he hoped that some of the 14,000 expelled under ‘don't ask, don't tell' could be reinstated, particularly if they were dishonourably discharged for being gay.

"It's the right thing to do, to go back and change those discharges," he said.

Alva was the first American soldier to be severely wounded in the Iraq invasion of 2003. He lost a leg to a landmine. He was a 13-year veteran at the time.

The 'don't ask, don't tell' policy came into effect 17 years ago, as a compromise between the Pentagon and then-President Bill Clinton. Under those rules, any service member who openly declares he or she is gay risks formal discharge from the military.

At the time, it took just 40 days to train U.S. forces on the policy.

According to researchers at the University of California, Santa Barbara, at least 25 countries around the world -- including Canada -- allow homosexuals to serve openly in the military.