People in violation of the new law will face up to three years in jail.

Switzerland has changed its penal code meaning that people who are homophobic or transphobic toward someone else face the same punishment as if they were racist toward them.

Switzerland’s National Council voted by 118-60 votes to update the penal code, and people who break the law could face up to three years in jail.

Mathias Reynard, who proposed the law celebrated its success. Posting on Twitter, he wrote: “Victory! By 118 against 60 and 5 abstentions, the National Council accepts my parliamentary initiative against homophobia and Transphobia!

“A great success for human rights! Final response in December to the Council of States.”

He finished his post with the hashtag LGBT and a Pride flag emoji.

Following the vote, Reynard said: “Homophobia is not an opinion. It’s a crime. One in five homosexuals attempted suicide, half before the age of 20. This victory sends a strong signal. I have already received hundreds of reactions.”

Speaking to Le Temps, Rene Schegg, the secretary general of LGBTQ group Pink Cross, said: “The decision of the day is an important step. It will likely bring Switzerland back to the rankings of the International Association of LGBTI People, where our country currently ranks 22nd behind Estonia and Hungary.”

Following Reynard’s victory he confirmed that he plans on introducing marriage equality to Switzerland. Since 2007, the country has offered civil partnerships, but same-sex couples don’t have the same rights when it comes to tax, fertility, welfare or adoption.

Related: Joe Biden says homophobia is a “disease” during LGBTQ dinner speech