Nevada has become the fourth state to prohibit the use of so-called gay and trans panic defenses, following California, Rhode Island and Illinois.

Senate Bill 97, which was signed into law Tuesday, prohibits defendants from using a victim’s sexual orientation, gender identity or gender expression as a defense in a criminal case.

Briana Escamilla, the Nevada state director for the Human Rights Campaign, a national LGBTQ group, said it was “long past time” for the state of Nevada to institute this legislation.

“These 'defenses' send the destructive message that LGBTQ victims are less worthy of justice and their attackers justified in their violence,” Escamilla wrote in an email. “Every victim of violent crime and their families deserve equal justice, regardless of their sexual orientation or gender identity.”

The bill was proposed by the Nevada Youth Legislature, a state program that gives high school students an opportunity to present bills to the Nevada Legislature.

Former Nevada state Sen. Valerie Wiener, a Democrat, told NBC News that Olivia Yamamoto, a high school student who is the chair of the Nevada Youth Legislature, was inspired to propose the bill after one of her classmates was murdered.

“These bills that the students propose in the Nevada Youth Legislature have real impact,” Weiner said. “They reflect what they’re experiencing and how courageous they are.”

Yamamoto’s classmate, Giovanni Melton, 14, was killed by his father after he discovered the teen had a boyfriend. Melton’s former foster mother said the father “would rather have a dead son than a gay son.”

Senate Bill 97 states that “‘gay panic’ and ‘trans panic’ defenses appeal to irrational fears and hatred of lesbian, gay, bisexual and transgender persons, thereby undermining the legitimacy of criminal prosecutions and resulting in unjustifiable acquittals or sentencing reductions.”

Perhaps the best known use of the “gay panic” defense in the U.S. was in the murder trial of Aaron McKinney and Russell Henderson, who were found guilty of first-degree murder in the 1998 death of Matthew Shepard. Shepard was a gay student at the University of Wyoming who was robbed, tortured, tied to a fence and left to die by McKinney and Henderson. In court, McKinney’s lawyer argued that his client was driven to temporary insanity following sexual advances by Shepard.

An extension of the “gay panic” defense — the “trans panic” defense — was employed following the murder of Gwen Araujo. Arajuo was a transgender woman who was strangled, beaten with a shovel and buried by a group of four men, two of whom she had been sexually intimate with, in 2002. One defendant's attorney said that his client was not biased and that he had been shocked "beyond reason" to learn he had unwittingly had sex with a man. Two of the defendants were convicted of second-degree murder, and the other two defendants pleaded guilty or no contest to voluntary manslaughter.

Brooke Maylath, a board member for the Reno-based Transgender Allies Group, told NBC News that passage of Senate Bill 97 is a “step forward for Nevada.”

“It’s not OK for people to leverage their stigma and further oppress a group of people who don’t deserve this horrible violence,” Maylath said. “It fights back against the notion that our lives are worth nothing. We have jobs, we pay taxes, we contribute to the betterment of society. In death, we should be treated with respect.”

FOLLOW NBC OUT ON TWITTER, FACEBOOK & INSTAGRAM