A majority in Brazil’s Supreme Court has voted in favour of making homophobia and transphobia crimes.
Six out of 11 judges voted to consider discrimination against gays and transgender people equivalent to racism.
The decision will give the community, which suffers constant attacks, real protection, activists say.
At least 141 LGBT people have been killed in Brazil this year, according to rights group Grupo Gay da Bahia.
The Catholic Church and the evangelical movement are frequently critical of gay rights and far-right President Jair Bolsonaro, elected last year with strong support of conservative voters, is a self-described homophobic.
“Homophobic crimes are as alarming as physical violence,” Supreme Court Vice-President Luiz Fux said on his vote, citing “epidemic levels of homophobic violence”.
For almost 20 years there have been efforts to make homophobia a crime in Brazil, but legislation on the matter has faced resistance among conservative and religious groups in Congress, the BBC’s Julia Carneiro in Rio reports.
The decision at the Supreme Court means that offences are to be punished under the country’s racism law until Congress approves specific legislation to protect LGBT people, our correspondent adds.
The remaining judges will vote in a session scheduled for 5 June.
Brazil has the world’s biggest Catholic population but also a growing number of young, educated urban liberals who are eager to fight for gay and trans rights.
The country legalised same-sex marriage in 2013 and LGBT couples have also been given the right to adopt.
Last year, 420 LGBT people were killed across Brazil, one of the most violent countries in the world, according to Grupo Gay da Bahia.
Some activists have raised concerns over the possibility of a rise in crimes against gays and transgender people with the election of Mr Bolsonaro, a deeply divisive figure who has also made racist and misogynist remarks.
In previous interviews, he has said he would rather have a dead son than a homosexual son. Last month, he was heavily criticised for saying Brazil should not become a “gay tourism paradise”.