Germany can bar EU migrants from certain social security benefits even if they have previously worked in Germany, the EU's top court has ruled.
The European Court of Justice (ECJ) ruling applies to all EU member states.
Even after six months' residence in an EU state a migrant may still be refused any social assistance, the ECJ ruled.
The judgement concerned a Bosnian-born Swedish national - Nazifa Alimanovic - who had claimed subsistence allowances after losing her job in Germany.
The UK Conservatives say the ruling strengthens Prime Minister David Cameron's hand in his push for major EU reforms.
Changes to EU policy on migrant benefits are a key part of his renegotiation, ahead of a UK in/out referendum on EU membership, set to take place by the end of 2017.
In 2012 a job centre in Berlin stopped paying social security to Ms Alimanovic. She and her daughter Sonita had been receiving unemployment benefits since December 2011. Child support had also been paid for two more children - Valentina and Valentino.
Denying certain non-contributory benefits - also called "social assistance" - to EU jobseekers from another EU country "does not contravene the principle of equal treatment", the ECJ said.
An ECJ ruling in November 2014 found that Germany also had a right to refuse benefits to EU migrants who had no intention of finding work in Germany, in the Dano case.
Ms Alimanovic's three children were born in Germany. The family had returned there from Sweden in 2010. Ms Alimanovic and her elder daughter had worked for less than a year before claiming benefits.
'Supports UK stance'
The Conservatives' employment spokesperson in Europe, Anthea McIntyre, called the ruling "a major endorsement of our stance on benefit tourism and our views on free movement.
"Increasingly the rest of Europe is seeing things our way. It bodes well for one of our key areas of renegotiation."
A UK government spokesperson said the ruling "shows we are right to restrict benefits going to EU nationals who haven't paid into the system in the UK.
"It is also further supports our argument that individual member states should have the freedom to design their own welfare systems without being constantly challenged by the courts."
The UK Independence Party (UKIP) - with 24 MEPs the largest British contingent in the European Parliament - said "abuse of the welfare system by non-nationals is also clearly becoming an issue in Germany".
"The [UK] government needs to examine this judgment closely, and if need be, look to alter the rules on habitual residence, which give EU migrants open access to many UK benefits, even though some of them in reality are not seeking work or have only worked for a very short time," said UKIP's employment spokeswoman Jane Collins.
A British Liberal Democrat MEP, Catherine Bearder, said the ruling had "huge implications for the current EU debate in the UK.
"It confirms that jobseekers from elsewhere in the EU are not automatically entitled to claim benefits. I hope the myth of benefit tourism will now be put firmly to bed."