LGBTQ rights scored a rare victory in Romania on Thursday after a top court ruled in favor of the rights of same-sex couples.

In a surprise verdict, Romania’s Constitutional Court claimed the right to privacy and a family for LGBTQ couples is guaranteed both by the country’s 1991 constitution and human rights guidelines passed by the European Union.

These couples should “benefit from…. legal and juridical recognition of their rights and obligations,” the court claimed.

Judges with the nine-person bench cited Article 26 of the Romanian Constitution in their ruling, which mandates that “public authorities… respect and protect the intimate, family, and private life.” The document further claims that individuals are guaranteed privacy unless it “infringes on the rights and freedoms of others, on public order, or morals.”

Article 7 of the Charter of Fundamental Rights of the EU comes to a similar conclusion. The European Union bylaws state that “everyone has the right to respect for his or her private and family life, home and communications.”

The ruling also alluded to similar guidelines passed by the European Convention for the Protection of Human Rights and Fundamental Freedoms.

This week’s decision is a major about face for the Constitutional Court after it allowed a national referendum on same-sex unions to move forward following a 7-2 ruling. In a two-day plebiscite held between Oct. 6 and 7, citizens will vote on whether to restrict Romania’s definition of marriage to “one man and one woman.

Currently, the Romanian Constitution defines marriage in gender-neutral terms, with Article 28 describing it as a union between “spouses.”

In 2016, more than three million Romanians signed a petition by the anti-LGBTQ Coalition for the Family to put the issue up for public vote. Orthodox and Catholic leaders have vocally supported the referendum, joined by the U.S.-based hate groups Alliance Defending Freedom and Liberty Counsel.

LGBTQ advocates claimed this week’s court ruling is a sign the plebiscite is “totally useless.”

“Today’s decision again confirms that the gay family is equal to any other family,” said Accept Vice President Romaniţa Iordache in a statement. “The referendum is becoming totally useless in every respect since the Constitution of Romania already respects the equality of a married heterosexual family and couples of the same sex.”

Currently, Romania is one of just six European Union member countries that do not offer relationship recognition for same-sex couples. The others are Bulgaria, Latvia, Lithuania, Poland, and Slovakia.

While the Constitutional Court ruling is critical because it cites the country’s own laws in affirming the right to marriage equality, it isn’t the first court victory for Romanian same-sex couples. The European Court of Justice ruled in July that LGBTQ couples in EU member countries are entitled to the same residency rights as their heterosexual counterparts.

That historic case originated in Romania. Adrian Coman, a Romanian national, wanted to be able to relocate to his home country with his American husband, Claibourn Robert Hamilton. The two were married in New York.

EU member nations “may not obstruct the freedom of residence” of same-sex couples, the European Court of Justice claimed.