The European Union's top court ruled on Tuesday that Britain could deny child benefit to foreigners who are not economically active in the country, one of the hot-button issues in Britain's looming referendum on EU membership.
The European Court of Justice said a rule that makes allowances conditional on the right to reside in Britain might amount to discrimination, but could be justified by a need to protect public finances.
The right to reside applies to foreigners who work, are looking for work or have been in Britain for at least five years.
The European Commission had argued that the British process of checking whether claimants of child benefit and child tax credit are legally resident discriminates against foreigners because British citizens are not checked in that way.
The court said the condition did not go beyond what is necessary to attain the objective of protecting its finances.
Catherine Bearder, Liberal Democrat member of the European Parliament (MEP) and a proponent of Britain staying in the European Union, called it a "landmark judgment."
"This ruling is a victory for Britain, confirming we have a fair immigration system as well as having full access to the EU single market," she said.
Conservative MEP Anthea McIntyre said the ruling was a victory for Britain and for common sense.
The ruling follows an opinion issued in October from a senior adviser to the court.
Since then, British Prime Minister David Cameron secured more freedom to curb UK benefits available to citizens of the other 27 EU member states in order to bring down the numbers of people migrating to Britain.
The court stresses its independence from politics, though EU officials say a number of recent decisions on benefits for migrants show a sensitivity to concerns in Britain and other member states that have sapped popular support for the EU.
UK-based think-tank IPPR said the judgment could be picked up by both sides of the June 23 referendum campaign.
For Remain, the court's support would be a boost, while for the Leave group, it would remind voters that Britain's welfare system is subject to EU law, IPPR research fellow Marley Morris said.
Other wealthier member states such as Germany also want to counter "benefits tourism" from poorer eastern European states which have joined the bloc since 2004.
A number of court judgments have underlined that free movement for EU citizens is principally restricted to those in work or seeking work, or their dependents. (Reporting by Philip Blenkinsop; Editing by Barbara Lewis and Ralph Boulton)