Emergency legislation to block the automatic release of people convicted of terror offences is set to become law after being approved by the Lords.
The Terrorist Offenders (Restriction of Early Release) Bill - which was passed by MPs earlier this month - was drawn up following an attack in south London.
The attacker, Sudesh Amman, had recently been freed from prison.
The government had wanted to pass the bill before 28 February when the next terror offender is due for release.
Sunderland shopkeeper Mohammed Zahir Khan, 42, had been set to be freed after serving half of his sentence for encouraging terrorism.
The government's emergency measures, which required backing from Parliament, would postpone his release until the Parole Board has given its approval.
How does automatic early release work?
Offenders are told they are being sentenced for a fixed period and will be automatically released at the half-way point, to serve the remainder of their sentence on licence in the community.
Some offenders will have pleaded guilty on the basis that they would be given a sentence with automatic early release at the half-way point.
Their release is an automatic process and does not involve oversight of the Parole Board.
The bill would affect about 50 prisoners who were convicted under existing rules, which allow for release halfway through a sentence.
Lawyers for some of the inmates are believed to be preparing a legal challenge, but ministers claim they are not extending sentences, merely changing the way they are administered.
The legislation would apply to England, Scotland and Wales but the government said it intended to make provisions for Northern Ireland in a future piece of legislation, arguing that there was no need for "immediate measures" in the region.
'An unusual step'
The House of Lords backed the bill unamended in one sitting on Monday evening.
During the debate, the government's justice spokesperson Lord Keen of Elie acknowledged that "applying these measures retrospectively is an unusual step" - but argued this was due to the "unprecedented gravity of the situation".
Labour's shadow attorney general Baroness Chakrabarti said she accepted the need for emergency legislation, but added that it was "an emergency of the government's own making".
She argued the Ministry of Justice had been hit by "the most savage cuts in Whitehall".
"That has a direct bearing on the nature of capacity, regime and intervention in the prison and probation systems."