FILE - A giant rainbow flag is pictured during the Gay Pride parade at Copacabana beach in Rio de Janeiro, Brazil, Sept. 30, 2018.
FILE - A giant rainbow flag is pictured during the Gay Pride parade at Copacabana beach in Rio de Janeiro, Brazil, Sept. 30, 2018.

SAO PAULO - The Brazilian Supreme Court ruled Thursday that homophobia should be criminalized under existing legislation until Congress creates a specific law for the subject, weighing in on a topic that has drawn the ire of President Jair Bolsonaro.

Eight of 11 justices voted to treat homophobia in the same way as racism under Brazilian law, making it a criminal act.

"Sexual orientation and gender identity are essential to human beings, to the self-determination to decide their own life and seek happiness," Justice Gilmar Mendes said, according to the court's Twitter account.

FILE - Brazil's President Jair Bolsonaro talks at the government house in Buenos Aires, Argentina, June 6, 2019.

During the court's deliberations last month, as it became clear that most justices would rule in favor of criminalizing homophobia, Bolsonaro strongly criticized the court. He accused the justices of legislating from the bench and suggested it was time to appoint an evangelical Christian to the Supreme Court.

Evangelicals and other socially conservative Brazilians helped Bolsonaro win last year's election as he promised to overturn years of liberal social policies, including more rights for same-sex couples.

Bolsonaro, a Catholic who was baptized by an evangelical pastor on a trip to Israel three years ago, had a history of making homophobic, racist and sexist public remarks before he took office in Jan. 1. He told one interviewer he would rather have a dead son than a gay son.