Large-scale immigration to the European Union has highlighted big differences in the way the 27 member states handle newcomers from non-EU countries.
African migrants risk their lives to reach the Canary Islands
The impetus for new EU-wide rules is fuelled by: the pace of globalisation; the need to attract more high-skilled workers as Europe's population ages and businesses struggle to compete; and an influx of illegal immigrants to Mediterranean countries.
European leaders have signed up to an immigration pact, paving the way for new laws to harmonise immigration policy in the EU. Yet it is an area where governments are often keen to retain a high degree of national control.
Is the EU failing to cope with illegal immigrants?
There are some real pressure points in the Mediterranean. Spain, Italy and Greece are struggling to manage large flows of illegal immigrants from developing countries, some of whom have grounds for claiming asylum.
The influx is a concern for other EU countries, as many illegal immigrants end up seeking work further north, in France and the UK, for example. There are an estimated eight million illegal immigrants in the EU, half of whom came in legally but overstayed.
This year, EU patrol boats have stopped more than 20,000 people trying to cross the Mediterranean from Africa, with record numbers reaching Malta and Sicily. Boatloads of African migrants continue to make the perilous journey to the Canary Islands, putting Spain's reception centres there under great strain.
Another area of concern is the EU's eastern border with the former Soviet Union. Despite enhanced border security, people traffickers regularly smuggle in migrants from the former Soviet Union and Asian countries, most of them fleeing poverty, but some also fleeing conflict and persecution.
Border checks are often minimal in the 24-nation Schengen zone, where passport-free travel is allowed.
Sweden says it received about 18,000 Iraqi asylum seekers in 2007 - more than half the total that entered the EU last year. Sweden has a well-established Iraqi community, but says other EU countries should take in a bigger share of Iraqis, who have mostly fled violence and poverty.
Italy's new right-wing government has launched a high-profile crackdown on illegal immigrants, mainly targeting Roma (Gypsies) living in squalid camps on the outskirts of major cities. Some of the measures - like fingerprinting children - have been strongly criticised at the EU.
How will the immigration pact change things?
The pact itself will have political rather than legal force - but related EU directives are likely to enshrine some of the principles in law.
The pact says the EU "does not have the resources to decently receive all the migrants hoping to find a better life here".
It says it is "imperative that each member state take account of its partners' interests when designing and implementing its immigration, integration and asylum policies".
It will make it harder for member states to grant mass amnesties for illegal migrants. In 2005 Spain granted an amnesty for about 700,000 illegal immigrants. By filling many jobs that Spaniards were unable or unwilling to take, migrants contributed to Spain's economic boom - before it was derailed by the credit crunch. But Spain's move was criticised by some of its neighbours, notably France. The new pact calls for "case-by-case regularisation, rather than generalised regularisation".
The pact says illegal immigrants must return to their countries of origin or to a country of transit. To that end, EU co-operation with those countries is to be enhanced, including strengthening of border controls.
The pact contains a pledge to beef up the EU's new border control agency Frontex, which has been hampered by insufficient resources.
What new measures are envisaged for illegal immigrants?
A "return" directive has been approved by the European Parliament and is expected to become law in two years' time.
It will apply across the EU, except in the UK and Ireland, which have not opted in to this area of Community law. The UK government does not believe the directive will make returning illegal immigrants any easier.
The EU legislation will apply only once a decision has been taken to deport an illegal immigrant - it is still up to each member state to decide whether it wishes to accept or deport the immigrant.
The deportation decision will be immediately followed by a voluntary departure period of up to 30 days maximum.
If the immigrant then refuses to leave, a removal order will be issued. If there is a risk the immigrant might abscond, the person can be detained. The maximum period of custody will be six months, which can be extended by a further 12 months in certain cases, if the immigrant fails to co-operate.
Member states can impose a re-entry ban of five years maximum if the person is deported after the voluntary return period has expired.
At present, detention periods for illegal immigrants vary widely across the EU. In the UK and six other countries detainees can be held indefinitely. The maximum in France is 32 days, in Latvia it is 20 months.
The "return" directive sets out safeguards for the return of unaccompanied children, prioritising "the best interests of the child".
Detainees will also have the rights to appeal against deportation, to see legal advisers, family members and get medical attention.
Are there any objections to this change in policy?
The UK government is among critics of the directive who say it will make returning illegal immigrants more difficult, by setting restrictions on detention and giving detainees more power to challenge deportation.
Amnesty International is among the critics who say the "return" directive should provide more human rights safeguards. It argues that detention "should only be used in very exceptional cases" and protests that the directive "will allow EU countries to detain people who have not committed any crime, including minors, for up to one year and a half".
France, current holder of the EU presidency, wanted the immigration pact to include "immigration contracts", obliging migrants to pass language and culture tests in the host country, but that idea was scrapped under Spanish pressure.
Some South American leaders have condemned the pact, with Venezuelan President Hugo Chavez threatening to cut off oil exports to the EU if it is adopted. South American countries, which took in many European migrants in the past, now provide many workers for the EU, especially Spain.
What will change for asylum seekers?
The EU aims to establish a Common European Asylum System. Currently the degree of protection afforded asylum seekers varies widely across the EU.
European leaders want the European Commission to present proposals by 2012 at the latest for setting up a single asylum procedure, with common guarantees.
Great emphasis is being placed on the "solidarity" principle to ease the burden faced by some EU countries: the EU plans to make it easier to reallocate asylum seekers geographically, working with the UN High Commissioner for Refugees.
How does the EU plan to attract more high-skilled workers?
The European Commission has highlighted the EU's need for high-skilled workers and hopes a "Blue Card" scheme will help solve the problem.
Many European enterprises complain that they cannot fill job vacancies. The EU's long-term demographic trend threatens to make the situation worse, because birth rates are generally low and ageing populations will create more gaps in the labour market.
In the EU's total employed population, 1.7% are highly qualified workers from non-EU countries. By comparison, that category of immigrants forms 9.9% in Australia, 7.3% in Canada and 3.2% in the US.
The EU Blue Card is aimed to rival the US Green Card in attracting much-needed high-skilled workers to the EU, such as computer engineers and nurses.
The card would give holders equal treatment to nationals in many areas and make it easier for them to bring their families over. Subject to certain conditions, they would be able to move to a second EU member state after two years' legal residence in the first state.
But there are still disagreements about which qualifications are to be included and how much the immigrants should earn. It has been argued that to qualify for a card, an immigrant should have been offered a job with 1.5 times the average salary in the country concerned.
Germany and Austria have not yet lifted restrictions on workers from the new EU member states - and the Czech Republic says the card should not be introduced until that happens, which could be as late as 2011.