U.S. Rep. Joe Kennedy during a news conference with members of the House leadership and the LGBT Equality Caucus (Justin Sullivan/Getty)

Democrats in Congress have filed a bill to outlaw the use of the ‘gay panic’ defence in the US.

The defence – which allows criminals to get more lenient sentences after violent attacks – is based around the suggestion that a perpetrator was “panicked” into committing a violent crime due to an unwanted advance from a gay person.

The best-known case of the gay panic defence was in the murder of US student Matthew Shepard.

He was killed in October 1998 on the outskirts of Laramie, Wyoming, by two men who met him in a bar, beat him, robbed him, and left him to die tied to a fence.

Aaron McKinney and Russell Henderson, both 21 at the time, attempted to argue in court that that they suffered “a moment of insanity” when Shepard made sexual advances towards them.

20 years on, Democratic lawmakers are hoping to make sure that the ‘gay panic’ defence, based on the flawed understanding that being approached by a gay person in some way mitigates the violent crime, is outlawed entirely.

Rep. Joseph Kennedy III and Senator Ed Markey this week filed the Gay & Trans Panic Defense Prohibition Act, a law that would ban use of the legal defence across the US.

Kennedy, the grandson of the late Robert F. Kennedy, said in a statement: “Murdering or assaulting anyone because of their sexual orientation or gender identity is not a defence, it is a hate crime.

“Legal loopholes written into our laws that seek to justify violent attacks against our gay, lesbian, bisexual, and transgender neighbors should never have existed in the first place.

“I am proud to introduce this legislation with Senator Edward Markey and believe that our colleagues will echo our urgency in ensuring hate does not live in our courtrooms.”

Senator Markey told the Washington Blade: “Gay and trans panic legal defences reflect an irrational fear and bigotry toward the LGBTQ community and corrode the legitimacy of federal prosecutions.

“These defecses must be prohibited to ensure that all Americans are treated with dignity and humanity in our justice system.”

To date, gay panic defences are only explicitly banned in California, Rhode Island and Illinois.

Earlier this year, a criminal was given a lighter sentence after stabbing his neighbour to death.

69-year-old James Miller was sentenced to six months in prison and 10 years probation over the killing of his neighbour Daniel Spencer.

His defence argued in court that the killing was in self-defence after Spencer made a sexual advance and became aggressive.

The gay panic defence relies on a largely discredited medical idea that many men will have a natural, biological response of rage when witnessing gay behaviour, which will make their actions uncontrollable.

Kennedy is one of the most active lawmakers in Congress on LGBT rights.