The court ruled that member states of the EU can refuse to provide social security payments that are not based on contributions to people living in the country whose residency is based only on their desire to find work, reports Spiegel.
The Luxembourg court said that to withhold the benefits was not in contravention of the basic right of EU citizens to equality of treatment.
The ruling came in the case of a Swedish woman who was denied Hartz IV - Germany's basic state welfare payment – six months after she started collecting the benefit in 2010.
In 2013 the woman took the local authority in Berlin's Neukölln neighbourhood to court over the refusal,. The federal social court then referred the case to the Luxembourg court after a series of appeals.
Tuesday's ruling means that EU citizens living in Germany will now only be able to collect Hartz IV – an unemplyment benefit of €399 a month – for a period of six months.
Only after five years' residency in Germany will they be entitled to the same benefits as German citizens.
In 2014 the same court ruled that Germany was allowed to deny benefits to European immigrants who came to the country 'exclusively for the purpose' of picking up social security payments. The court ruled that such a measure was justified to prevent 'benefit tourism.'
There had previously been confusion about foreigners' entitlement to German benefits, with one local court and the EU Commission suggesting that denying EU citizens the same benefits as Germans contravened their right to equality of treatment.