European Union member states have agreed that illegal immigrants can be detained for up to 18 months and face a five-year re-entry ban in a move which critics say will undermine human rights.
The EU says the directive will establish a common set of rules for illegal immigrants in the member states.
The draft law is yet to be agreed by EU lawmakers.
Officials say the European parliament is deeply split on the issue and it is unclear if a vote set for next month will go ahead then.
The 18-month limit is higher than the maximum detention in two- thirds of the 27 EU states.
Although EU states can keep a lower limit if they want, rights groups say it will tend to encourage authorities to lock up more illegal migrants.
The European Commission estimates there are up to 8 million illegal immigrants in the bloc.
More than 200,000 were arrested in the EU in the first half of 2007, fewer than 90,000 were expelled.
Children can also be detained according to the text agreed by EU envoys, which says that this should be for the shortest appropriate period of time.
Currently, illegal immigrants cannot be detained for more than 40 days in Spain and a year in Hungary, according to European Commission data.
Germany already has an 18-month detention cap, while eight EU countries, which have higher caps or none at all, would need to introduce the new EU limit.
The new limit will be based on a first cap of six months that can be extended to 18 months under certain circumstances, including if the illegal migrant does not cooperate with the authorities.
The EU move comes after Italy yesterday made illegal immigration a jailable offence.