WASHINGTON  The Senate has agreed to expand the definition of hate crimes to those committed because of a victim’s sexual orientation and gender identity as part of a Pentagon policy measure that is becoming a magnet for tough social issues.

Senators added the anti-bias provisions to the bill Thursday night after voting 63 to 28 to shut off debate on the proposal by Senator Patrick J. Leahy, Democrat of Vermont and chairman of the Judiciary Committee. The measure would also allow the federal government to intervene in cases where the local authorities lacked the resources for such criminal investigations.

“We need a strong federal law to serve as a backstop to prevent hate-motivated violence in America,” Mr. Leahy said.

Republicans countered that the hate crimes expansion should not be part of a Pentagon measure and argued that it would usurp the rights of states to pursue such crimes since most have their own versions of the law.