The European Commission has threatened legal action against the UK, saying a test of eligibility for benefits discriminates against foreigners. The \"right to reside\" qualification for benefits is automatic for UK nationals but assessed for other EU nationals. The commission said this breached EU law and gave the UK two months to say how it would bring its rules into line. The government said Britons \"should be gravely concerned\" at EU erosion of states\' rights to run their affairs. Ministers fear taxpayers could be forced into handing out more than £2bn to EU nationals, including so-called \"benefits tourists\". A range of UK benefits - child benefit, child tax credit, state pension credit, jobseekers\' allowance and unemployment support allowance - are given only to those with a \"right to reside\". But the European Commission says the assessment of that for overseas nationals is a breach of EU social security co-ordination rules giving all citizens equal rights. \"The Commission may decide to refer the UK to the EU\'s Court of Justice,\" it said in a statement. Writing in the Daily Telegraph on Friday, UK Work and Pensions Secretary Iain Duncan Smith said: \"These new proposals pose a fundamental challenge to the UK\'s social contract. \"They could mean the British taxpayer paying out over £2bn extra a year in benefits to people who have no connection to our country and who have never paid in a penny in tax.\" He added: \"The EU settlement is supposed to protect the right of member states to make their own social security arrangements. \"But we are now seeing a rising tide of judgements from the European institutions using other legal avenues to erode away these rights, and we should be gravely concerned.\"