Joint Chiefs Chairman Adm. Mike Mullen also was present for the occasion.
The repeal "will strengthen our national security and uphold (America's) ideals," Obama said. "No longer will tens of thousands of Americans in uniform be asked to live a lie."
"I believe this is the right thing to do for our military," he added. "It's the right thing to do, period."
This is a moment "more than two centuries in the making," the president said. Over the course of U.S. history, "gay Americans fought just as hard (and) gave just as much to protect" the country as anyone else. "We are a nation that believes all men and women are created equal."
Passage of the repeal was a major political victory for Obama and congressional Democrats. Obama promised to repeal the ban during the 2008 presidential election.
The crowd chanted "Yes we can" as Obama was introduced before the bill signing -- a reference to Obama's campaign slogan.
Massachusetts Rep. Barney Frank, an openly gay Democrat, called the bill's passage "the biggest single thing" in terms of the progress of gay rights in the United States.
"To see the president today put ink to paper and sign this into law, its been a tremendous day," said Air Force Lt. Col. Victor Fehrenbach. "He made a promise to me a year-and-a-half ago. He looked me in the eye and said, 'I'm going to get this done.'"
Air Force veteran Jeff Cadavona said Wednesday's signing was a long time coming.
"When I was in the military in the '60s -- that hammer over you for being openly gay," he said. "If they found you out, they'd kick you right out."
The change won't be immediate, however. The White House has noted that the repeal may take several months to implement.
The Pentagon has an 87-page implementation plan for the repeal of "don't ask, don't tell." Over the next several weeks, military officials need to examine and rewrite a series of policies, regulations and directives related to the current law.