Puerto Rico’s Supreme Court on Wednesday voted 5-4 to ban gay couples from adopting children, with judges claiming that a child’s dignity, stability and well-being can only be ensured if raised in a “traditional” family.

The vote comes two days after 200,000 religious Christians held a rally against granting same-sex couples any sort of legal rights. As the largest anti-gay rally in the history of the US commonwealth, the gathering portrayed the immense opposition gay couples continue to face in Puerto Rico.

Although some lawmakers support granting gay couples with certain legal rights, many public figures remain starkly opposed to the idea. The Supreme Court decision came in response to a woman’s eight-year-long attempt to adopt a 12-year-old girl that her partner had given birth to through in vitro fertilization. Even though the woman’s girlfriend was the mother of the girl, the court upheld the constitutionality of a law that prohibits someone in a same-sex relationship from adopting the child.

“The state … does not have a constitutional obligation to award this relationship the same rights that other relationships have when it comes to adoption procedures,” read the majority’s opinion, which also added that children would only receive a good upbringing if raised by both a mother and father.

The Supreme Court majority also said that second-parent adoptions, which would allow same-sex couples to jointly adopt children, do not apply in Puerto Rico because US territory laws do not have a solution for that kind of a situation. The judges said that rather than take the issue to court, same-sex couples trying to adopt a child should instead ask legislators to change the law.

The court’s ruling prevents the 12-year-old girl from receiving the woman’s medical insurance and prevents the woman from gaining custody of the girl if her birth mother ever died. Because the girl has no legal ties to the woman who helped raise her, she is deprived from financial benefits that translate from parents to a child.

Chief Justice Federico Hernandez Denton, who voted against the ban, said the law is unconstitutional and that the plaintiff’s lawyer’s have successfully proven that the 12-year-old benefited from being raised by two women, AP reports.

“Both (women) have ideal emotional skills, intuition and protective instinct to guarantee the girl’s full and health development,” he wrote. “In addition, tests showed that (the girl) is mentally stable, does exceptionally well in school and gets along very well with children her age.”

But both the court and the territory remain divided about the idea of granting same-sex couples with legal rights. Protesters who rallied outside the Capitol on Monday denounced legislation that would protect same-sex couples from domestic violence and condemned legislation that would ban employment and housing discrimination based on someone’s sexual preference. The Supreme Court’s decision further demonstrates the wave of opposition gay couples face in the US territory that has not yet embraced the idea of homosexual relationships.