Defendants accused of murder in New York will no longer be able to plead those charges down to manslaughter by saying their actions were the result of an extreme emotional disturbance on discovering that someone is gay or transgender.

Lawmakers in the state Legislature gave final passage to a bill Wednesday to remove that option, commonly called the “gay panic” or “trans panic” defense.

The measure has support from Gov. Andrew Cuomo, who said he'll sign it when it comes to his desk. He's held several events in recent weeks calling on lawmakers to approve the bill.

“This year as part of our Justice Agenda we set out to build on these historic achievements by banning the so-called gay and trans panic legal defense, which essentially codified homophobia and transphobia into state law,” Cuomo said. “With the enactment of this measure we are sending a noxious legal defense strategy to the dustbin of history where it belongs.”

The bill wouldn't eliminate the option completely for defendants to say they were influenced by an extreme emotional disturbance, but it would set limits on that defense.

Defendants facing murder charges would no longer be able to plead them down to manslaughter by saying their actions were driven by the discovery of a victim's sexual orientation, gender, gender identity, gender expression or sex assigned at birth, according to the text of the bill.

It was partly inspired by the story of a transgender woman, Islan Nettles, who died in 2013 after she was struck by a man who discovered her gender identity.

Her assailant was sentenced to 12 years in prison after saying that, when Nettles revealed she was transgender, he became enraged and attacked her because of it. He later turned himself in to the police and entered a guilty plea.

Assemblyman Danny O'Donnell, a Democrat from Manhattan who sponsors the bill, referenced Nettles on the floor of the Assembly before the bill was approved Wednesday afternoon.

“The reality is that we as a community need to stand up and say we're not going to take this,” O'Donnell said. “We're not going to say it's OK to bash a trans woman's head into a street in Harlem merely because they exist.”

It passed the Assembly with only one vote in the negative from Assemblyman Anthony Palumbo, a Republican and criminal defense attorney on Long Island. The bill was approved unanimously in the State Senate, where it's sponsored by State Sen. Brad Hoylman.

“No longer, once we pass this bill, would a victim's sexual orientation or gender identity or expression be weaponized against them after their murder,” Hoylman said before the vote.

The bill had support from the New York State Bar Association. Hank Greenberg, the newly minted president of the State Bar, even joined Cuomo in recent weeks at a public event to advocate for the bill.

The LGBT Bar Association of New York has pushed for the change for years, and celebrated its passage in a statement Wednesday.

“LGBTQ New Yorkers will no longer have to live in fear that being out could provide justification for a defendant's violence against them. Our identities are not an 'excuse' for murder,” said Eric Lesh, executive director of the LGBT Bar. “The availability of these defenses in our system sent a message to LGBT people that their lives are not equal.”

The bill was opposed by a coalition of public defender organizations in New York City. They wrote in a recent memo to lawmakers that eliminating the defense would lead to more defendants serving longer sentences in state prison. The groups argued that the legislation would encourage incarceration, rather than benefit the LGBTQ community.

“Increased dependence on criminalization and incarceration, and on the tools of the state used to lock more people in cages, will not bring an end to discrimination and violence against LGBTQ+ people,” the groups wrote. “By eliminating this defense, we will be providing the state with yet another tool to incarcerate more people.”

The Legal Aid Society, Bronx Defenders, Brooklyn Defender Services, New York State Association of Criminal Defense Lawyers and others were on the memo.

The legislation hadn't received much attention this year until Cuomo included it on a list of his top priorities for lawmakers to address before the end of this year's legislative session. He's previously credited state Sen. Brad Hoylman, D-Manhattan, and O'Donnell for bringing the issue to light in recent years.

The bill will take effect immediately after it's signed by Cuomo. He has to wait for lawmakers to send it to him for a signature, which could happen at any time since it's now passed both houses.

READ MORE: