The murder of Matthew Shepard in 1998 is one of the most famous cases of the 'gay panic' defence being used (Evan Agostini/Getty)

A legal defence that justifies the murder of LGBT+ people may soon be banned in New Jersey, making the state one of only eight others to scrap the law.

The ‘gay panic defence’, as it is known, justifies violence against LGBT+ people by claiming that finding out a victim’s sexuality or gender identity caused the defendant to suffer from a state of temporary insanity.

So far, the only states that no longer allow this defence are California, Illinois, Rhode Island, Connecticut, Hawaii, Maine, Nevada and New York.

On January 13, the New Jersey state assembly voted by an overwhelming majority of 76-0 to give final legislative passage to a bill addressing the defence. The bill (A1796) will now head to Governor Phil Murphy, who must decide whether to sign it into law or veto it by January 21.

“The ‘gay panic or trans panic’ defence is not a freestanding defence to criminal liability, but rather a legal tactic,” the bill’s sponsor, assemblyman John McKeon, said in a statement.

“It’s used to diminish the reason for a defendant’s violent reaction that asks a jury to find a victim’s sexual orientation or gender/expression as the cause.

“Whether the person was gay, transgender or heterosexual, sexual orientation should not have any bearing on determining a person’s guilt in a murder trial.”

At least one man accused of murder in New Jersey has attempted to use the gay panic defence in the past decade.

The most well-known instance of the defence being used was the Matthew Shepard case in 1998. Shepard, a gay college student, was murdered and in court the defendant said he was not responsible for his actions because Shepard had made unwanted sexual advances.

The judge rejected it, but it sparked conversation about the validity of the defence. But it wouldn’t be until 2014 when California would become the first state to ban it.