The Canary Islands are struggling with an influx of migrants
The European Parliament has passed a controversial set of EU rules for dealing with illegal immigration.
Under the new rules illegal immigrants can be detained for up to 18 months and face a five-year re-entry ban.
Lawmakers backed the measures by a large majority despite opposition from many Socialist and Green parties, and condemnation from human rights groups.
The rules took more than two years to draft and member states will have a further two years to implement them.
The length of time an immigrant can be held before expulsion varies greatly across the 27-nation European Union.
In France the detention limit is 32 days, in Hungary it is a year, in Latvia it is 20 months and in seven countries there is no time limit.
France's immigration minister said that the country's custody period - the lowest in Europe - will not be altered.
Those with longer time limits will have to apply the new EU-wide maximum - however, the new rules will not automatically apply in Denmark, Ireland and the UK because they have negotiated opt-outs.
In the text approved by EU ministers, an illegal immigrant can be detained for a maximum of six months. This period is extendable by a further 12 months under certain conditions if, for example, the immigrant fails to co-operate with the authorities.
The new rules allow for a 30-day voluntary departure period for illegal immigrants before their expulsion.
Once expelled, they may be barred from re-entering the EU for a five-year period.
'Imperfect but necessary'
"We believe that the text approved today by the European Parliament does not guarantee the return of irregular migrants in safety and dignity," human rights group Amnesty International said in a statement.
EU officials estimate there are up to eight million illegal immigrants in the bloc.
According to the Council of Europe - a human rights watchdog - some 51,000 migrants arrived by boat in Italy, Spain, Greece and Malta in 2007, many of them asylum seekers and refugees "who lack legal avenues to enter Europe".
It urged the EU to improve the immigrants' detention conditions and legal aid, and said Mediterranean countries needed EU help to cope with the influx.
In a parliamentary debate on the new directive on Tuesday, EU Commissioner Jacques Barrot said the legislation "gives priority to voluntary returns" and "protects the rights of children and families".
Parliament's rapporteur Manfred Weber, who helped draft the directive, said it envisaged "the use of detention only when necessary" and it complied with Council of Europe guidelines.
A British liberal, Baroness Sarah Ludford, said it was "imperfect but necessary to raise standards".