The European Court of Justice's (ECJ) ruling on Tuesday refers to a case which predates the refugee debate dominating politics across the 28-nation bloc.
In 2013, before the current influx of migrants, a Ghanaian woman, Selina Affum, was apprehended in France as she was about to enter the Channel Tunnel while taking a bus from Belgium to the United Kingdom, which is not a member of the passport-free Schengen zone.
She presented only a Belgian passport with another name and photograph, upon which French authorities took her into custody for illegally entering the country.
Affum challenged the arrest and a French court asked the ECJ to rule whether she could be imprisoned based on EU return directives. The directives are designed to establish common standards and procedures for member states when removing non-EU nationals who are staying in their territory illegally.
"The Return Directive prevents a national of a non-EU country who has not yet been subject to the return procedure being imprisoned solely because he or she has entered the territory of a Member State illegally across an internal border of the Schengen area," the court said in a statement.
Detention undermines rules' effectiveness
The ECJ ruled that France could not imprison someone for entering its territory without permission because it undermined the effectiveness of EU rules and ultimately slowed down the return of illegal migrants to their country of origin or a country of transit.
The decision refers also to those who illegally cross the internal borders of the Schengen zone or those arrested trying to leave the zone, such as from France to the United Kingdom.
Bloc members can only imprison people who illegally entered their territory if they are suspected of or have committed a crime; they have stayed on after the process of deportation; they have returned after being deported; or if processing their legality could be "compromised."
Importantly, the court found that EU directives do not prevent non-EU nationals from being placed in "administrative detention" while authorities determine whether or not their stay is illegal. Some EU member states are either holding or considering holding migrants in temporary detention pending the processing of applications to stay.
Tuesday's ruling could have implications for how EU member states handle an influx of refugees and economic migrants both within the bloc and on its external borders. Many member states are clamping down on economic migrants with no chance of asylum in order to make room for those fleeing war and persecution.