In a landmark case for marriage equality, the EU’s top court, the European Court of Justice, ruled that same-sex spouses have the same residence rights as straight couples despite the individual marriage laws of EU countries.

The highly publicized case began in 2012 when Romanian LGBT activist, Adrian Coman, and his US partner, Robert Clabourn Hamilton, who were legally married in Belgium in 2010, attempted to relocate to Coman’s home country.

Romania doesn’t allow same-sex marriage so immigration authorities refused to legally recognize their marriage certificate, and therefore would not give Hamilton permission to live in the country for more than three months as he could not be classified as Coman’s spouse.

The decision led the couple to sue the Romanian government on the grounds that their right to freedom of movement within the EU, which is granted to the spouses of straight EU citizens, had been violated.

On Tuesday the court ruled that the term “spouse” in EU law includes partners of the same sex and instructed other EU countries to recognise the residency rights of all spouses regardless of whether they allow same sex marriage.

The Luxembourg-based court said that member states have the freedom to choose whether to recognize same sex marriage, however “they may not obstruct the freedom of residence of an EU citizen by refusing to grant his same-sex spouse, a national of a country that is not an EU Member State, a derived right of residence in their territory,” the Luxembourg-based court said.

The ruling means that any same sex couple, in which one person is from outside of the EU, would be able to gain residency in a country within the bloc regardless of whether that nation legally recognizes same sex partnerships.

Homosexuality was decriminalised in Romania in 2000, but the community still face discrimination within the country, according to LGBT activists.