Lawmakers have passed legislation that removes a controversial “gay panic” defense from the criminal code in an Australian state.

The code previously enabled the measure to be used as a partial defense to murder if an unwanted sexual advance had been made toward the accused in Queensland.

It was most famously used in 2008 when 45-year-old Wayne Ruks was killed by two men, Jason Pearce and Richard Meerdink, who claimed Ruks made advances at one of them.

Murder charges were reduced to manslaughter as a result, despite Ruks' family disputing any notion that he was gay at the time.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

Very proud to pass legislation abolishing the gay panic defence in Qld. https://t.co/CRhFguJGOV — Yvette D'Ath (@YvetteDAth) March 21, 2017

Queensland Attorney-General and Minister for Justice Yvette D’Ath said removing the defense had addressed an unacceptable inequality.

"Queensland's criminal code must not be seen to condone violence against the gay community, or indeed any community," D’Ath said in a statement released Tuesday.

“The passing of this legislation sends an important message that discrimination is not acceptable and that we value the LBGTI community.”

Ruks was found dead in the churchyard of Father Paul Kelly, a Catholic priest who subsequently led a campaign to have the law changed.

“After five years of relentlessly campaigning for the gay panic defense for murder to be scrapped from the legal books in Queensland, I can today breathe a sigh of relief and accomplishment,” Kelly said.

Kelly started a Change.org petition that racked up 290,000 signatures and told the Sydney Morning Herald newspaper in 2011 that the law was a "homophobic, demeaning, dangerous insult" to gay people. He added that it "allows killers to walk away with paltry sentences"

BREAKING: ‘Gay panic’ defence for murder abolished in QLD in one of biggest petition victories in Australia’s history-290k made this happen pic.twitter.com/N1HgHryDlP — Change.org Australia (@ChangeAus) March 21, 2017

Wayne Ruks’ mother, Joyce Kujala, said she had waited a long time for the change in the law.

“It can’t bring Wayne back, but it’s some small justice, and it could save a lot of lives in future,” Kujala said.

Follow NBC Out on Twitter, Facebook and Instagram