A UK "right to reside" test on EU nationals based in the country is a breach of EU law, the European Commission warned today.
Brussels threatened it will take legal action unless the test - which determines who qualifies for specific social security benefits - is dropped.
A Commission statement said the Government has two months to advise Brussels what it is doing to bring domestic social security rules in line with EU requirements.
"Otherwise, the Commission may decide to refer the UK to the EU's Court of Justice," said a statement.
Conservative MEP Julie Girling slammed the move as an interference by "unelected bureaucrats" in UK domestic policy.
Ms Girling, the Tory spokesman on employment and social affairs in the European Parliament, went on: "British taxpayers will want to know why their hard-earned money should now be directed straight into the pockets of any EU national who chooses to come here and make a claim.
"This can only lead to a boom in benefits tourism. And with our generous system, Britain will be destination of choice."
Under UK rules a range of benefits - child benefit, child tax credit, state pension credit, jobseekers' allowance and unemployment support allowance - are only given to those with a "right to reside".
That is automatic for UK nationals , but residents from other EU countries have to pass a "right to reside" test.
This, says the Commission, means the UK is indirectly discriminating against nationals of another member state, in breach of EU social security co-ordination rules under which EU citizens have the same rights and obligations as nationals of their host country.
And, insists the Commission, EU-level rules on who qualifies as a resident of a different member state are strict enough to make sure that "only those persons who have actually moved their centre of interest to a member state (other than their own) are considered habitually resident there".
The Commission cites the example of a worker who moved to the UK from Italy in 2009 after living in Italy for 20 years. She worked in the UK for an Italian company for two years until April 2009, paying taxes and national insurance contributions until she was made redundant.
And yet, said the Commission, her claim for income-based jobseekers' allowance was refused on the grounds that she did not have a right to reside in the UK.
"If the UK had applied EU social security co-ordination rules, those citizens confirmed as habitually resident in the UK would enjoy the same protection as habitual resident in other EU member states," the Commission said.
UK Independence Party leader Nigel Farage said: "Once again we see the Commission telling us how to run our country and people are becoming sick and tired of it.
"The UK is perfectly within its rights to require EU nationals to fulfil certain conditions before taking advantage of our generous benefits system.
"If the EC gets its way then there will be a far greater burden on the British taxpayer as more money will need to be found for the social security system."
He added: "The 'right to reside' test should stay. It is not discrimination, but simply a system to ensure that benefits are only paid to those who are entitled to them."
Employment Minister Chris Grayling said: "This is a very unwelcome development. It's obviously right that we support those who work and pay their taxes here, but it's clearly completely unacceptable that we should open our doors to benefit tourism.
"I'm really surprised that the European Commission has chosen to go into battle on this very sensitive issue, when there are clearly far more pressing problems to solve in Europe."