BUCHAREST (Reuters) - Romania must give residency rights to the same-sex spouses of European Union citizens, the socially conservative country’s top court ruled on Wednesday.

The Constitutional Court’s landmark ruling comes after a six-year legal battle of Romanian citizen Adrian Coman whose American husband, Robert Claibourn Hamilton, was denied residency because gay marriage is illegal in Romania.

The couple, who married in Brussels, took their case all the way to the Constitutional Court last year, which then referred it to the European Court of Justice.

In June, the ECJ ruled that European Union states which have not legalized gay marriage must still offer same-sex spouses residency rights equal to those of straight couples.

“In the arguments of the ruling, the Court has applied the considerations mentioned by the ECJ,” the Romanian judges said in a statement.

Romania does not recognize gay marriage conducted abroad and is one of a handful of EU states that do not offer civil partnerships. Few politicians openly support same sex unions in Romania, where the Orthodox Church yields significant influence.

“We consider the court’s decision an important signal for the political class, which must look at the LGBT community carefully and approve a law that legalizes civil partnerships soon, to recognize gay couples, both from Romania and abroad,” LGBT rights group MozaiQ said.

However, a group called Coalition for the Family gathered 3 million signatures in 2016 to hold a referendum to change the constitutional definition of marriage to a union strictly between a man and a woman, from the existing “spouses”.

The head of the ruling Social Democrats has said he hoped to organize the referendum this year, while also leaving open the possibility of civil partnerships.

If passed, the referendum would effectively rule out the possibility of legalizing same-sex marriage in the future.