Brazil’s top court officially criminalised homophobia and transphobia on Thursday, in a ruling that comes amid fears that the country’s far-right administration would roll back LGBT+ rights.

The court said the ruling addressed a legal shortfall that failed to protect the LGBT+ community, and now frames homophobia and transphobia as crimes within Brazil’s law against racism.

Offenders could now face prison sentences of up to five years.

According to the rights group the Grupo Gay da Bahia, 420 LGBT+ people were killed across Brazil in 2018, while at least 141 have been killed so far this year.

Brazil also leads the world in transgender homicides with 171 in 2017, according to the organisation Transgender Europe. Someone is killed in a homophobic attack here every 16 hours.

Jair Bolsonaro: Brazil's far-right leader inauguration Show all 20 1 /20 Jair Bolsonaro: Brazil's far-right leader inauguration Jair Bolsonaro: Brazil's far-right leader inauguration Brazil's new President Jair Bolsonaro waves as he drives past before his swear-in ceremony Reuters Jair Bolsonaro: Brazil's far-right leader inauguration Supporters wait in front of the Planalto Palace, where he will take office EPA Jair Bolsonaro: Brazil's far-right leader inauguration Jair Bolsonaro gestures at the Congress before he is sworn AFP/Getty Jair Bolsonaro: Brazil's far-right leader inauguration Supporters take pictures as Brazil's new President Jair Bolsonaro drives past Reuters Jair Bolsonaro: Brazil's far-right leader inauguration Flanked by first lady Michelle Bolsonaro, Brazil's President Jair Bolsonaro waves to the crowd, as he rides in an open car after his swearing-in ceremony AP Jair Bolsonaro: Brazil's far-right leader inauguration Jair Bolsonaro reacts as he drives past Reuters Jair Bolsonaro: Brazil's far-right leader inauguration Brazil's new President Jair Bolsonaro reacts as he drives past before his swear-in ceremony, in Brasilia, Brazil January 1, 2019. REUTERS/Ricardo Moraes RICARDO MORAES Reuters Jair Bolsonaro: Brazil's far-right leader inauguration The National Congress before Brazil's President-elect Jair Bolsonaro is sworn in AFP/Getty Jair Bolsonaro: Brazil's far-right leader inauguration Jair Bolsonaro gestures at the Congress AFP/Getty Jair Bolsonaro: Brazil's far-right leader inauguration Brazil's new President Jair Bolsonaro waves as he drives past before his swear-in ceremony, in Brasilia, Brazil January 1, 2019. REUTERS/Ricardo Moraes RICARDO MORAES Reuters Jair Bolsonaro: Brazil's far-right leader inauguration Supporters of Brazil's President Elect Jair Bolsonaro are cooled down with a water hose by firefighters, prior Bolsonaro's inauguration, in Brasilia, Brazil, Tuesday Jan. 1, 2019. (AP Photo/Silvia Izquierdo) Silvia Izquierdo AP Jair Bolsonaro: Brazil's far-right leader inauguration The presidential convoy, led by Brazil's President-elect Jair Bolsonaro (L) and his wife Michelle Bolsonaro in a Rolls Royce, heads to the National Congress for his swearing-in ceremony, in Brasilia on January 1, 2019. - Bolsonaro takes office with promises to radically change the path taken by Latin America's biggest country by trashing decades of centre-left policies. (Photo by Carl DE SOUZA / AFP)CARL DE SOUZA/AFP/Getty Images CARL DE SOUZA AFP/Getty Jair Bolsonaro: Brazil's far-right leader inauguration epa07257163 Sympathizers of Brazilian President-elect, Jair Bolsonaro, walk past a giant figure of the future president before the beginning of the inauguration ceremony, in Brasilia, Brazil, 01 January 2019. A far-right president leads the biggest Latin America democracy for first time since the end of military rule (1964-1985). Bolsonaro defeated candidate Fernando Haddad in the runoff, held in October 2018, receiving 55 percent of the vote. EPA/Fernando Bizerra Jr Fernando Bizerra Jr EPA Jair Bolsonaro: Brazil's far-right leader inauguration Brazil's President-elect Jair Bolsonaro (L) gestures next to his wife Michelle Bolsonaro as the presidential convoy heads to the National Congress for his swearing-in ceremony, in Brasilia on January 1, 2019. - Bolsonaro takes office with promises to radically change the path taken by Latin America's biggest country by trashing decades of centre-left policies. (Photo by Carl DE SOUZA / AFP)CARL DE SOUZA/AFP/Getty Images CARL DE SOUZA AFP/Getty Jair Bolsonaro: Brazil's far-right leader inauguration Firefighters spray water at supporters of Brazilian President-elect Jair Bolsonaro to cool them down, while they gather to wait for his inauguration ceremony at "Tres Poderes" square in front of the Planalto Palace in Brasilia, on January 01, 2019. - Brazil entered a new chapter in its history on Tuesday, embracing a far-right president, Jair Bolsonaro, whose determination to break with decades of centrist rule has raised both hopes and fears. (Photo by EVARISTO SA / AFP)EVARISTO SA/AFP/Getty Images EVARISTO SA AFP/Getty Jair Bolsonaro: Brazil's far-right leader inauguration Supporters take pictures as Brazil's new President Jair Bolsonaro drives past before his swear-in ceremony, in Brasilia, Brazil January 1, 2019. REUTERS/Ricardo Moraes RICARDO MORAES Reuters Jair Bolsonaro: Brazil's far-right leader inauguration Brazil's new President Jair Bolsonaro and his wife, Michelle Bolsonaro, arrive at Brazil's National Congress, in Brasilia, Brazil January 1, 2019. REUTERS/Pilar Olivares PILAR OLIVARES Reuters Jair Bolsonaro: Brazil's far-right leader inauguration Supporters of Brazilian President-elect Jair Bolsonaro, gather at the "Tres Poderes" square in front of the Planalto Palace in Brasilia, before his inauguration ceremony on January 01, 2019. - Brazil entered a new chapter in its history on Tuesday, embracing a far-right president, Jair Bolsonaro, whose determination to break with decades of centrist rule has raised both hopes and fears. (Photo by EVARISTO SA / AFP)EVARISTO SA/AFP/Getty Images EVARISTO SA AFP/Getty Jair Bolsonaro: Brazil's far-right leader inauguration Supporters of Brazilian President-elect Jair Bolsonaro, gather to wait for his inauguration ceremony at "Tres Poderes" square in front of the Planalto Palace in Brasilia, on January 01, 2019. - Brazil entered a new chapter in its history on Tuesday, embracing a far-right president, Jair Bolsonaro, whose determination to break with decades of centrist rule has raised both hopes and fears. (Photo by EVARISTO SA / AFP)EVARISTO SA/AFP/Getty Images EVARISTO SA AFP/Getty Jair Bolsonaro: Brazil's far-right leader inauguration Jair Bolsonaro addresses Congress, during his swearing-in ceremony as Brazil's new president, in Brasilia on January 1, 2019. - Bolsonaro takes office with promises to radically change the path taken by Latin America's biggest country by trashing decades of centre-left policies. (Photo by NELSON ALMEIDA / AFP)NELSON ALMEIDA/AFP/Getty Images NELSON ALMEIDA AFP/Getty

“In a discriminatory society like the one we live in, the homosexual is different and the transsexual is different,” said Justice Carmen Lucia.

“Every preconception is violence, but some impose more suffering than others.”

The supreme court’s intention had already been voiced in late May after six of the 11 judges had voted in favour of the measure, but was suspended until the other judges voted.

The final votes came in on Thursday, making the ruling official with a tally of eight votes in favour and three against.

After President Jair Bolsonaro took office on 1 January 2019, Brazil was seen to be turning sharply against LGBT+ rights and feminism.

The president has a history of homophobic, transphobic and racist remarks, having in the past bragged that he was “homophobic, and very proud” and that he’d rather have a dead son than a homosexual son.

In late April, he caused outrage saying Brazil should not be “the country of gay tourism”.

As Mr Bolsonaro campaigned last year, reports of crimes against LGBT+ people tripled.

Brazil had already legalised same-sex marriage, along with Argentina, Colombia and Uruguay. On Wednesday, Ecuador became the latest South American country to join when its highest court approved same-sex marriage in a landmark ruling for the country.

Additional reporting by AP.