The case involved two Syrians who travelled to Germany in 1998 and 2001 respectively and were granted subsdiary protection status - one step down from qualifying as refugees.
German authorities imposed residence conditions on them but the pair challenged the decision in Germany's Federal Administrative Court, which referred it to the European Court of Justice.
"The (EU) Directive does not prevent beneficiaries of subsidiary protection status from being subject to a residence condition for the purpose of promoting their integration, even if that condition does not apply to other non-EU citizens legally resident in Germany," the court ruled.
The ECJ said that European Union laws meant that normally people in their position should be able to move freely in the country that granted them protective status and choose their place of residence, the same as any other non-EU national.
It ruled that EU states could not tell people where to live in order to balance the distribution of social benefits.
But it said it was up to the German court to decide if national authorities could impose restrictions if they judged that people with subsidiary protection status "face greater difficulties relating to integration than other non-EU citizens legally resident in Germany."