The decision from the unelected upper house, which is being seen as a humiliating slap in the face for the Government, was immediately attacked as a “threat to public safety.”
The Immigration Bill debate hinged on how long would-be immigrants should be detained at immigration centres.
Currently immigrants can be held indefinitely but peers voted for a cap of 28 days.
Critic Lord Keen of Elie, who is also the Advocate General for Scotland, claimed the move would jeopardise safety and security in the UK, and said: “Such an amendment would significantly impact on our abilities to enforce immigration controls and maintain public safety.”
The Lords voted 187 to 170 for the limit, which can only be extended by a court.
Crossbench peer Lord Green of Deddington said the 28-day time limit could lead to up to 10,000 people a year appealing