President Obama signed into law the Matthew Shepard & James Byrd Jr. Hate Prevention Act during a White House signing ceremony on Wednesday.

The legislation expands the definition of federal hate crimes to include sexual orientation and gender identity.

“After more than a decade of opposition we passed inclusive hate crimes legislation to help protect our citizens from violence based on what they look like, who they love, how they pray or who they are,” Obama said before signing the bill.

Democrats stowed away the bill inside the must-pass fiscal year 2010 defense reauthorization bill, a move that rankled some Republicans.

As senators debated the bill last Thursday, South Carolina Senator Jim DeMint called the bill “offensive.”

“It suggests that violence against certain kinds of victims is worse, more in need of federal intervention and swift justice,” he said. He added that the bill decides which thoughts are criminal and which are not.

Opponents argue that the bill will have a chilling effect on free speech and restrict religious liberties, despite its included First Amendment protections.

International civil rights groups hailed passage of the bill, saying it puts the U.S. at the forefront of civil rights.

“The adoption and enforcement of this bill sets the stage for further comprehensive reforms at home and adds momentum to U.S. efforts to continue its leadership in combating the scourge of hate crimes abroad,” Paul LeGendre, director of Human Rights First's Fight Discrimination Program, said in a statement.

The bill is named for Matthew Shepard, a 21-year-old student at the University of Wyoming who was killed in 1998 by two men he met in a gay bar, and James Byrd Jr., a black man dragged to death behind a pickup truck a year earlier in Texas. Shepard was beaten and left to die shackled to a post along a rural road near Laramie. Judy Shepard devoted herself to passage of the bill named after her son.

The bill defines hate crimes as those motivated by prejudice against race, color, religion, national origin, gender, sexual orientation, gender identity and disability. It allows the Attorney General to assist cities and sates in the investigation and prosecution of hate crimes.

House lawmakers approved a similar bill in 2007, but it sank in the Senate under the weight of a veto threat from President George Bush. President Obama had urged lawmakers to approve the measure.