Image copyright AFP

On 6 July, a motion in the House of Commons calling on the government to guarantee the rights of EU nationals living in the UK was passed by 245 votes to two.

It is not binding on the government, which said it would be a mistake to give guarantees to EU nationals in the UK without similar concessions for UK nationals living elsewhere in the EU.

How do the numbers compare?

The UK has a population of 63.7 million, of which 5.3 million (8%) are non-British, and just over half of those - 2.9 million (5%) - are from Europe.

Just under 1.2 million UK nationals live elsewhere in the EU.

Of the non-British population from EU countries, the largest group was Polish nationals, with about 853,000, according to the latest Office for National Statistics (ONS) Population of the United Kingdom by Country of Birth and Nationality report.

The Irish were the second-largest group, with 331,000 residing here. Romanian and Portuguese nationals are in joint third place, with 175,000 people from each country living in Britain.

These figures include only those living in the UK for at least a year.

Polish Prime Minister Beata Szydlo has already said that the country would work in negotiations to "ensure that Poles living in Great Britain retain their privileges".

The Irish government has also announced its contingency plans now that the UK has voted to leave the EU, including making preparations for increased numbers of UK citizens applying for Irish passports.

Of those 2.9 million EU nationals living in the UK, about 2.15 million are working.

Five years ago that figure was 1.33 million and 10 years ago it was 758,000.

There are about 1.19 million non-UK nationals from outside the EU working in the UK.

The figure of just under 1.2 million UK nationals living in the rest of the EU comes from the United Nations.

These are the best statistics available, although they are not perfect, with some countries counting international migrants by birthplace while others judge by the passport someone holds.

Of the 27 EU countries, Spain had the most UK nationals with just under 310,000 migrants from the UK living there in 2015. Ireland was second with 255,000 and France third with 185,000.

Of those UK nationals in Spain, 106,610 were claiming the UK state pension, according to figures from the Department for Work and Pensions, while 133,250 pensioners were living in the Republic of Ireland.

Read more: The facts behind claims about our relationship with the EU