To assure its passage after years of frustrated efforts, Democratic supporters attached the measure to a must-pass $680 billion defense policy bill the Senate approved 68-29. The House passed the defense bill earlier this month.
Many Republicans, normally staunch supporters of defense bills, voted against the bill because of the hate crimes provision. All the no votes were Republicans except for Sen. Russ Feingold, D-Wis., who supported the hate crimes provision but opposes what he says is the open-ended military commitment in Afghanistan.
"The inclusion of the controversial language of the hate crimes legislation, which is unrelated to our national defense, is deeply troubling," said Sen. Jeff Sessions, R-Ala.
Hate crimes law enacted after the assassination of Martin Luther King, Jr., in 1968 centered on crimes based on race, color, religion or national origin.
The expansion has long been sought by civil rights and gay rights groups. Conservatives have opposed it, arguing that it creates a special class of victims. They also have been concerned that it could silence clergymen or others opposed to homosexuality on religious or philosophical grounds.
Joe Solmonese, president of the Human Rights Campaign, the nation's largest gay rights group, hailed the bill as "our nation's first major piece of civil rights legislation for lesbian, gay, bisexual and transgender people. Too many in our community have been devastated by hate violence."
Some 45 states have hate crimes statutes, and the bill would not change current practices where hate crimes are generally investigated and prosecuted by state and local officials.
But it does broaden the narrow range of actions - such as attending school or voting - that can trigger federal involvement and allows the federal government to step in if the Justice Department certifies that a state is unwilling or unable to follow through on an alleged hate crime.
The measure also provides federal grants to help state and local governments prosecute hate crimes and funds programs to combat hate crimes committed by juveniles.
"As we learned in the civil rights era, sometimes communities need assistance and resources from the federal government when they have to confront the most emotional and dangerous kinds of crimes," said Sen. Michael Bennet, D-Colo.
The bill also creates a federal crime to penalize attacks against U.S. service members on account of their service.
Attorney General Eric Holder said nearly 80,000 hate crime incidents have been reported to the FBI since he first testified before Congress in support of a hate crimes bill 11 years ago. "It has been one of my highest personal priorities to ensure that this legislation finally becomes law," he said.
The FBI says more than half of reported hate crimes are motivated by racial bias. Next most frequent are crimes based on religious bias, at around 18 percent, and sexual orientation, at 16 percent.
At the urging of Republicans the bill was changed to strengthen free speech protections to assure that a religious leader or any other person cannot be prosecuted on the basis of his or her speech, beliefs or association.
"Nothing in this legislation diminishes an American's freedom of religion, freedom of speech or press or the freedom to assemble," said Sen. Ben Cardin, D-Md. "Let me be clear. The Matthew Shepard Hate Crimes Prevention Act targets acts, not speech."
That didn't convince Sen. Jim DeMint, R-S.C., who said the bill was a "dangerous step" toward thought crimes. He asked whether the bill would "serve as a warning to people not to speak out too loudly about their religious views."
Tony Perkins, president of the conservative Family Research Council, said the measure was "part of a radical social agenda that could ultimately silence Christians and use the force of government to marginalize anyone whose faith is at odds with homosexuality."