BRUSSELS (Reuters) - Some migrants can be told where they must live in the European Union as long as the reason is to help them integrate into society, the EU’s top court ruled on Tuesday.

Migrants stand next to the Greek-Macedonian border fence, near the Greek village of Idomenii March 1, 2016. REUTERS/Marko Djurica

The ruling applied to migrants granted so-called subsidiary protection - not qualifying as refugees but in need of international protection - and may as a result apply more broadly to all those granted asylum.

The European Court of Justice said that in general migrants with protected status should be allowed to move freely and choose their place of residence.

The local authorities could not, as some had sought, set a residence condition in order to ensure a balanced distribution of the costs of social benefits.

But the court said EU law did not prevent a residence condition for the purpose of promoting integration, even if that condition does not apply to other non-EU citizens.

The case was brought by a German court looking into disputes between two local authorities in northern Germany and two Syrian nationals who arrived in Germany in 1998 and 2001.

Both were granted protected status, received social security benefits and were issued with a residence permit subject to the condition that they lived in a particular place, a condition the two challenged.

The EU court said it was for the German court to determine whether people faced greater difficulties integrating than other non-EU citizens residents receiving social benefits.

In 2015, the EU’s 28 countries granted asylum in 252,230 cases, of which nearly three-quarters were deemed to be refugees and the remainder given humanitarian or subsidiary protection status, according to EU statistics agency Eurostat.

Refugees are those fleeing persecution for reasons of race, religion, nationality, membership of a particular social group or political opinion. Others fleeing conflict in general or natural catastrophes may also qualify for protection while not considered as refugees.