A majority in Brazil's supreme court has voted to make homophobia and transphobia crimes like racism, a decision coming amid fears the country's far-right president will roll back LGBTQ social gains.

Six of the Supreme Federal Tribunal's 11 judges have voted in favor of the measure. The five other judges will vote in a court session on June 5, but the result will not be modified. The measure will take effect after all the justices have voted.

Racism was made a crime in Brazil in 1989 with prison sentences of up to five years. The court's judges ruled that homophobia should be framed within the racism law until the country's congress approves legislation specifically dealing with LGBTQ discrimination.

Brazil's Senate is dealing with a bill to criminalize discrimination based on sexual orientation or gender with sentences of up to five years.

"Racism is a crime against flesh and blood, whether it is a member of the LGBT community, a Jew or an Afro-descendant," justice Luiz Fux said Thursday.

The court's judges said the ruling was to address an omission that had left the LGBTQ community legally unprotected.

While same-sex marriage is legal in Brazil, it is still a dangerous country for members of the LGBTQ community and has a large evangelical movement often critical of gay rights. According to the rights group the Grupo Gay da Bahia, 420 LGBTQ people were killed across Brazil in 2018, while at least 141 have been killed so far this year.

President Jair Bolsonaro, a former army captain who assumed office on Jan. 1, has a history of offensive comments about gays, blacks and other minorities, openly acknowledging he is a homophobe. He has said he would rather have a dead son than a gay son.

The ruling "comes at a very good moment, when we have a head of state who is LGBT-phobic," said Bruna Benevides, president of the Niteroi Diversity group. "The Supreme Court assumed the responsibility to protect us."

FOLLOW NBC OUT ON TWITTER, FACEBOOK & INSTAGRAM