WASHINGTON – President Obama signed a new law Wednesday that will allow gays for the first time in history to serve openly in America’s military. And he urged those kicked out under the old law to re-enlist.

Framing the issue as a matter of civil rights long denied, Obama said that “we are a nation that welcomes the service of every patriot … a nation that believes that all men and women are created equal.”

Repealing the 17-year-old policy known as “don’t ask, don’t tell” in a ceremony that was alternately emotional and rousing, the president said that “this law I’m about to sign will strengthen our national security and uphold the ideals that our fighting men and women risk their lives to defend.”

The law ends a policy that forced gays to hide their sexual orientation or face dismissal. More than 13,500 people have been discharged under the rule since 1993.

“I hope those … who’ve been discharged under this discriminatory policy will seek to re-enlist once the repeal is implemented,” Obama said.

“I hope so too,” agreed Zoe Dunning, a former naval officer now with the advocacy group Servicemembers Legal Defense Fund.

“We are in two wars and we need qualified candidates,” Dunning said after the ceremony. She said it was unclear how many people discharged under the old law might seek to rejoin, and whether all “have completely healed … (and) trust the military is going to treat them fairly.”

The question of reinstating those previously discharged was addressed in a months-long study done by the Pentagon earlier this year on how the armed forces might go about implementing a repeal of don’t ask, don’t tell.

The study recommended that the Department of Defense issue guidance to all the service branches permitting those previously separated on the basis of homosexual conduct “to be considered for re-entry, assuming they qualify in all other respects.”

It said the fact that they were kicked out for gay conduct should not be held against them, but added that if they received an “other than honorable” discharge for accompanying reasons, those reasons should be considered.

A beaming Obama signed the bill at the Interior Department, a location chosen to accommodate a larger-than-normal audience for a bill signing.

“I say to all Americans, gay or straight, who want nothing more than to defend this country in uniform, your country needs you, your country wants you, and we will be honored to welcome you into the ranks of the finest military the world has ever known,” Obama said. “No longer will tens of thousands of Americans in uniform be asked to live a lie.”

As military leadership and advocacy groups have warned in recent days, Obama also noted that the repeal will not go into effect until the government goes through additional steps to roll back the old policy.

Gay troops would still be vulnerable to being discharged until Pentagon officials first complete mandatory implementation plans — and the president, defense secretary and chairman of the joint chiefs certify to lawmakers that the move won’t damage combat readiness, as critics charge.

Speaking to reporters later in the day, Obama said he spoke to the military service chiefs about readiness after Congress voted for repeal.

“They have all said that we are going to implement this smartly and swiftly, and they are confident that it will not have an effect on our military effectiveness. So I’m very heartened by that,” Obama said.

Opponents of the repeal have argued that the move would harm unit cohesion, could prompt some to leave the services or not sign up in the first place, and will remain a distraction at a time when the armed forces are fighting two wars.

But Obama said: “We are not going to be dragging our feet to get this done.” White House spokesman Robert Gibbs said Obama thinks actual implementation of the new law will be “a matter of months.”

Pentagon personnel chief Clifford Stanley and his staff have already started working on an action plan based partly on recommendations from the study. The plan will look at a host of questions, from how to educate troops on the change to how sexual orientation should be handled in making barracks assignments.

The president vowed during his 2008 campaign to repeal the law, and faced pressure from liberals who complained he was not acting swiftly enough.

For Obama, it was the second high-profile bill-signing ceremony within a week, coming after Friday’s approval of a tax package he negotiated with Republicans.

Those attending Wednesday’s ceremony included Dunning, the son of a World War II veteran who was saved by a gay comrade during the Battle of the Bulge, and Marine Staff Sgt. Eric Alva, the first American wounded in the war in Iraq who has since spoken out against the Pentagon policy.

Gay-rights activists and other supporters packed into the room hooted, applauded and shouted in joy to the president.

“We’re here, Mr. President. Enlist us now!” someone said from the back of the room as Obama signed the bill.