“Reality will very soon make it clear that there is nothing to worry about,” Mr. Frank said. He called the signing the biggest civil rights moment in the nation since the signing of voting rights legislation in the 1960s. “If you can fight for your country, you can do anything,” he said.

In the years since President Bill Clinton first enacted “don’t ask, don’t tell” in 1993, some 17,000 service members have been discharged under the policy. While many gay people in the military are now breathing a sigh of relief, the Servicemembers Legal Defense Network, which represents soldiers facing charges under the policy, is warning its members that they are “still at risk” because the repeal will not take full effect until 60 days after Mr. Obama, the defense secretary and admiral certify readiness.

“The bottom line is DADT is still in effect and it is not safe to come out,” the organization said.

For Mr. Obama, the ceremony  held at the Interior Department because the White House is tied up with holiday tours  marked yet another in a string of last-minute, bipartisan legislative triumphs, a surprising turnaround in the wake of the self-described “shellacking” his party took at the polls last month. He had already signed a bipartisan tax deal into law, and the Senate appears headed on Wednesday to approve a new nuclear arms pact with Russia, which will give him a significant foreign policy victory as he wraps up the first half of his term. He looked relaxed and upbeat as he soaked up the energy from an enthusiastic crowd.For the gay rights movement, which has been frustrated with the pace of progress under Mr. Obama, Wednesday marked a celebratory turning point. “Thank you, Mr. President,” someone shouted, as Mr. Obama took the stage, prompting a round of other shouts: “Chicago’s in the house, Mr. President! You rock, Mr. President!” Mr. Obama pronounced himself overwhelmed.

The audience for the ceremony included a who’s who of gay activists, among them Frank Kameny, who was fired from a civilian job as an Army astronomer in 1957  an act that prompted him to found a gay rights advocacy organization in Washington D.C. and to file a lawsuit which went all the way to the Supreme Court. In 1965 he picketed the White House, in the first ever demonstration there by gays.

Now white-haired at 85, Mr. Kameny also served as an enlisted Army soldier; he signed up in May 1943, he said, three days before he turned 18, and saw “front line combat” in Germany during World War II. He said he was asked if he had “homosexual tendencies” and denied it. “They asked, and I didn’t tell,” he said, “and I resented for 67 years that I had to lie.”