Emergency legislation to prevent the automatic release from prison of terrorist offenders will become law later this week, just before the next terrorist prisoner is eligible to be freed.

The Terrorist Offenders (Restriction of Early Release) Bill has cleared the Commons and was backed unamended in one sitting by peers.

The plans, which will affect around 50 prisoners, aim to make sure terrorist offenders serve two-thirds of their sentence before they are considered eligible for release.

Before being freed they would need to be reviewed by a panel of specialist judges and psychiatrists at the Parole Board.

According to the Henry Jackson Society, those who had been due for release in the coming days and weeks include Mohammed Ghani, from Barnet, north London, who was sentenced to two years and four months in prison in May last year after threatening to kill police officers.

There is also Mohammed Khilji, from north-west London, who was jailed for five years in June 2018 after being found guilty of posting beheading videos on WhatsApp, as well as footage giving advice on how to make a car bomb.

And Sunderland shopkeeper Mohammed Zahir Khan, originally from Birmingham, who posted messages and material that was supportive of IS on social media, was jailed for four-and-a-half years in May 2018.

The release date change follows the Streatham terror attack earlier this month in which Sudesh Amman stabbed two bystanders with a knife he had grabbed from a shop.

The 20-year-old had been jailed in December 2018 for possessing and distributing terrorist documents but had been freed midway through his sentence less than a fortnight before the attack.

It was the second attack in three months by a convicted terrorist, after Usman Khan stabbed and killed two people at Fishmongers' Hall near London Bridge in November.

He had been released nearly a year earlier, halfway through a 16-year jail sentence.

Despite cross-party criticism of the retrospective nature of the emergency legislation, the Bill was given an unopposed second reading in the Lords and passed its committee stage unamended.

For the Government, Lord Keen of Elie said Parliament must put a stop to arrangements that allowed a "dangerous terrorist to be released from prison by automatic process of law before the end of their sentence".

Lord Keen said automatic halfway release was "simply not right in all cases" and emergency laws were required with further releases due in days.

The aim was to "standardise the earliest point" at which terrorist offenders may be considered for release at two-thirds of the sentence imposed and require the Parole Board to assess whether the prisoner is safe to release.

Lord Keen acknowledged that applying the legislative provisions retrospectively was an "unusual step" but insisted it reflected the "unprecedented gravity of the situation" and the "danger posed to the public".