FILE PHOTO - Soldiers of the presidential guard with the Supreme Court building in the background stand at Planalto Palace in Brasilia, Brazil May 11, 2016. REUTERS/Adriano Machado

SAO PAULO (Reuters) - The Brazilian Supreme Court ruled on 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.

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.