text: An independent report commissioned by the Department of Health estimated these groups cost the NHS £2bn a year.
  Ministers said some of that spending was unavoidable, but said it would be realistic to save a quarter.
  Savings would come from deterring so-called health tourism, recovering money owed by other countries and a levy on non-European temporary residents.
  One senior doctor questioned the government's figures and said doctors should not have to spend time "vetting eligibility" of patients.
  Health Secretary Jeremy Hunt said he did not want to "turn GPs into border guards" and no-one would be denied emergency treatment, but foreign visitors must make a "fair contribution".
  Mr Hunt said he recognised the NHS's duty of care must "transcend" financial concerns, but collecting an extra £500m a year could pay for 4,000 extra doctors.
  "We have one of the most generous systems in the world when it comes to healthcare for foreign visitors, but it's time for action to ensure the NHS is a national health service - not an international one," he added.
  By Nick TriggleHealth correspondent
  The issue of which foreigners are entitled to treatment and which are not is complex.
  The first thing to say is if someone needs emergency care - for example if they have an accident - the NHS will treat them no matter where they come from.
  Another exemption is if someone has an infectious disease as treatment helps protect the wider public.
  Beyond that the UK has reciprocal agreements with most European countries and 28 other nations, including countries such as Canada and Australia.
  It means if their residents need care while here temporarily - either on holiday or working - they will be seen and the NHS will then reclaim the cost of that care from the other country.
  The research released by the Department of Health shows the NHS is not very good at clawing that money back. This is because of a perverse incentive in the system which ministers now want to rectify.
  Meanwhile, travelling to the UK deliberately for health treatment - so-called health tourism - is not allowed.
  The rules are less clear in other cases, such as expats and asylum seekers.
  The latest research is published in two separate reports by firms Prederi and Creative Research.
  The government has been criticised for using financial estimates from the Prederi report, but Mr Hunt said it was the "most thorough research there has ever been" in this area.
  The report itself notes that it is based on "incomplete data, sometimes of varying quality, and a large number of assumptions", but it says the estimates are the "best that can be made at present", and Mr Hunt said researchers had been "completely honest about what they do know and what they don't know".
  The government is currently consulting on the measures it will take to tackle this issue.
  It has already announced a £200-a-year levy on migrants from outside the European Economic Area (EEA) staying for between six months and five years, and Mr Hunt said this could raise £200m a year.
  A cost-recovery unit will also be set up to help hospitals claw back money they are owed by other governments for treating foreign nationals visiting the UK.
  Meanwhile, "deliberate health tourism" - whereby people travel to the UK to get NHS care - is estimated by Prederi to cost between £60m and £80m a year. The report's authors concede this figure is "uncertain" and the "plausible range" of the cost is £20m-£100m.
  Frequent visitors "taking advantage" by registering with GPs and getting access to prescriptions and some hospital referrals cost the NHS a further £50m-£200m a year, the report adds.
  The government accepts it cannot recoup all of this money and entirely stop health tourism and so it has put forward the "conservative" £500m figure.
  To achieve this, it said a better system of identifying when visitors and migrants got treatment was needed. More details on what this will involve will be revealed in the coming weeks.
  Free NHS care is offered to anyone with living in the UK who has temporary or permanent permission to do so.
  Asylum seekers, non-EEA nationals who do not have permission to live in the UK, British ex-pats and visitors usually have to pay for treatment.
  The UK has reciprocal agreements with most European nations and 28 other countries, and under these visitors are given free NHS care.
  The NHS should claim these costs back from the relevant governments - but the research suggests just £73m a year is recouped out of more than £460m at present.
  This is because there is a perverse incentive in the system whereby if they declare the fact they have treated a foreign national it is up to the individual hospital to chase up the home nation for the money whereas if they do not declare it they get money from the NHS system for seeing a patient entitled to care.
  Shadow health secretary Andy Burnham said: "We are not against improving the recovery of costs from people with no entitlement to NHS treatment."
  But he added the figures were based on a "large number of assumptions" and was more about "spin than substance".
  Dr Chaand Nagpaul, chairman of the British Medical Association's GPs committee, said the government's £500m savings figure was "exaggerated", partly because it did not take account of the costs of implementing its plans.
  He said migrants paying the proposed £200-a-year levy could be more likely to use the NHS to "get their money's worth", and he said the cost of a single hospital outpatient appointment would be more than £200.
  Dr Nagpaul said doctors should not be distracted from their work in order to check the eligibility of patients for treatments.
  Dr Clare Gerada, chairwoman of the Royal College of GPs, said it was imperative GPs were not tasked with being a "new border agency" in policing the NHS.
  "The risks to public health that will arise from these proposals are also very real. They will deter people from seeking medical help in the early stages of illness when they can be dealt with cost-effectively and efficiently in primary care, rather than requiring expensive specialist care and increasing admissions to emergency departments," she said.
  Jonathan Portes, of the Institute of Economic and Social Research think tank, said the research revealed the extent of deliberate health tourism had been "hugely overstated" and was in fact a "very small part of NHS expenditure".
target: Up to £500m could be recovered from overseas visitors and migrants using the NHS every year, ministers believe.