STRASBOURG, France  European Union lawmakers voted Wednesday to allow undocumented migrants to be held in detention centers for up to 18 months and banned from European Union territory for five years.

Criticized by groups like Amnesty International as “severely flawed” and an erosion of human rights standards, the so-called return directive was passed in the European Parliament here by a 369-to-197 vote, with 106 legislators abstaining.

Manfred Weber, the German center-right legislator from Bavaria who shepherded the measure through Parliament, said that it provided minimum common standards for the treatment of migrants throughout the European Union while still showing citizens it was tough on illegality.

As for the migrants, he said: “The member states must decide whether they need them; if so, then please legalize them. If you don’t need them for your labor markets, then send them home.”