Washington (CNN) -- President Obama on Wednesday signed a law that makes it a federal crime to assault an individual because of his or her sexual orientation or gender identity.

The expanded federal hate crimes law, hailed by supporters as the first major federal gay rights legislation, was added to a $680 billion defense authorization bill that Obama signed at a packed White House ceremony.

The hate crimes measure was named for Matthew Shepard, a gay Wyoming teenager who died after being kidnapped and severely beaten in October 1998, and James Byrd Jr., an African-American man dragged to death in Texas the same year.

Shepard's mother, Judy, was among those at the ceremony that also included Vice President Joe Biden, Defense Secretary Robert Gates, Attorney General Eric Holder and leading members of Congress and the Pentagon, who were on hand for the appropriations bill signing.

To loud applause, Obama hailed the hate crimes measure in the bill as a step toward change to "help protect our citizens from violence based on what they look like, who they love, how they pray."

He cited the work of the late Sen. Edward Kennedy of Massachusetts and others "to make this day possible."

Later Wednesday, Obama stood with Shepard's parents and relatives of Byrd at a separate White House event honoring passage of the expanded hate crimes law.

Noting reports of 12,000 crimes based on sexual orientation over the past 10 years, Obama called the bill another step in the continuing struggle for protecting human rights.

"Because of the efforts of the folks in this room, particularly those family members standing behind me, the bell rings even louder now," Obama said. When he finished his remarks, he hugged the weeping relatives as the audience applauded.

Several religious groups have expressed concern that a hate crimes law could be used to criminalize conservative speech relating to subjects such as abortion or homosexuality. However, Holder has said that any federal hate-crimes law would be used only to prosecute violent acts based on bias, not to prosecute speech based on controversial racial or religious beliefs.

Former President George W. Bush had threatened to veto a similar measure, but Obama brought a reversal of that policy to the White House.

When the bill won final congressional approval last week, Human Rights Campaign president Joe Solmonese called the hate crimes measure "our nation's first major piece of civil rights legislation for lesbian, gay, bisexual and transgender people."

Earlier this month, Obama told the Human Rights Campaign, the country's largest gay rights group, that the nation still needs to make significant changes to ensure equal rights for gays and lesbians.

"Despite the progress we've made, there are still laws to change and hearts to open," he said in an address at the group's annual dinner. "This fight continues now and I'm here with the simple message: I'm here with you in that fight."

Among other things, Obama has called for the repeal of the ban on gays serving openly in the military -- the "don't ask, don't tell" policy. He also has urged Congress to repeal the Defense of Marriage Act and pass the Domestic Partners Benefit and Obligations Act.

The Defense of Marriage Act defines marriage, for federal purposes, as a legal union between a man and a woman. It allows states to refuse to recognize same-sex marriages. The Domestic Partners Benefit and Obligations Act would extend family benefits now available to heterosexual federal employees to gay and lesbian federal workers.

However, some advocates for stronger rights for the lesbian-gay-bisexual-transgender community have complained that Obama's administration is moving too slowly on his legislative promises.

Opponents of the expanded hate crimes bill challenged the need to specify one particular community in federal legislation. They contended that existing federal hate crimes laws were sufficient to protect the rights of people based on sexual orientation and gender identity.

More than 77,000 hate-crime incidents were reported by the FBI between 1998 and 2007, or "nearly one hate crime for every hour of every day over the span of a decade," Holder told the Senate Judiciary Committee in June.

At Wednesday's signing, Obama also praised what he called a bipartisan effort to start changing the culture of military spending through the annual appropriations bill. He noted that Gates had worked with congressional leaders to end what Obama called wasteful projects like the F-22 fighter bomber and a new presidential helicopter that would have cost "almost as much as Air Force One."

"I won't be flying on that," the president said.

Noting that cost overruns in military projects total tens of billions of dollars, Obama called for further "fundamental" reforms in how the government and Pentagon do business.

"We all know where this kind of waste comes from," he said, citing "indefensible" no-bid contracts and special interests pushing unneeded weapons systems.

Such actions are "inexcusable", "unconscionable" and an "affront to the American people" as the nation faces two wars and an economic recession, Obama said.

"Today I'm pleased to say that we have proved that change is possible," he said.