About 50 prisoners convicted of terror offences will no longer be automatically freed halfway through their sentences, under emergency government legislation designed to prevent further jihadi attacks by recently released inmates.

The urgent introduction of a parliamentary bill on Tuesday – due to become law before the end of the month – is aimed at pre-empting the release of any more prisoners serving a fixed-length terrorist sentence.

The move follows the London Bridge knife attacks by Usman Khan in November last year and the Streatham stabbings by Sudesh Amman this month. Both men were convicted terrorists released mid-term from prison on licence.

Most of the 50 or so inmates affected by retrospective changes to enforcement of their sentences are believed to be serving time for jihadism-related crimes, though others may be far-right activists.

Of the 224 inmates serving time for terror-related offences in British prisons in September last year, 77% were classed as having Islamist extremist views and 17% were deemed to support far-right ideologies.

A total of 53 prisoners held for terror offences were released in the year up to the end of June 2019.

The Henry Jackson Society, a thinktank, estimates there are 11 terror offenders on fixed sentences who would have been eligible for early release this year before the law was changed, including five individuals who would otherwise have been freed in late February and early March.

The first is Mohammed Zahir Khan, a shopkeeper from Sunderland, who was sentenced to four years and six months in May 2018 at the age of 40 for nine counts of sharing Islamist material on social media and encouraging religious hatred, including by tweeting support for Isis and calling for the death of Shia Muslims. He is understood to have been due for automatic release on 28 February.

Others that the thinktank says are due for automatic release in March include Mohammed Ghani, from Barnet, north London, who in 2019 was sentenced to 28 months for four offences including threatening to kill police officers in a call to 999 and possessing the Isis propaganda magazine Inspire.

Mohammed Khilji, from Brent, north-west London, who was jailed in June 2018 for five years on eight counts of encouraging terrorism by sharing graphic videos of Isis beheadings and videos calling for violence against non-Muslims, was also due to be freed shortly.

Aras Hamid, jailed for eight years in January 2017 for trying to leave the country and travel to Syria to join Isis, would have been eligible for release this year. He was arrested in the back of a lorry in a layby at Dover. Hamid has also tried to make arrangements for others to travel to Syria, and was found to have possessed what the Crown Prosecution Service said was large quantities of terrorist material.

The government argues the changes, though applying to those already behind bars and effectively retrospective, do not alter the total length of sentences imposed by the courts.

Instead of being freed automatically halfway through their sentence, inmates will be forced to spend a minimum of two-thirds of their term behind bars before being referred to the Parole Board, which will consider their release. Those receiving sentences for offenders of particular concern (SOPCs) will also be affected.

The legislation will cover England, Wales and Scotland but not Northern Ireland. Anyone sentenced to less than two years for relatively minor terror offences – such as wearing a uniform or displaying an article of a proscribed organisation – will be excluded from the changes.

Robert Buckland, the justice secretary, said: “No dangerous terrorist should be released automatically only to go on to kill and maim innocent people on our streets. Enough is enough. This government will do whatever it takes to keep the public safe, including making sure no terror offender is released early without a thorough risk assessment by the Parole Board.

“We are [also] stepping-up deradicalisation measures in our prisons, introducing a 14-year minimum for the worst terrorist offenders, and giving more money to the police to deal with these horrific crimes.”

Priti Patel, the home secretary, said: “Recent months have been a stark reminder of the threat we continue to face from terrorism. We are determined to ensure that dangerous terrorists are not free to spread their hateful ideologies or harm the public.

“We are already boosting funding for counter-terrorism police and victims of terrorism and this legislation will ensure terrorist offenders are not released early unless there has been a full assessment of the risks.”

The government has separately pledged to introduce tougher sentences for serious terrorist offenders and a 14-year minimum for the worst terrorist offenders. It is also ending any early release from custody for those receiving an extended determinate sentence. Polygraph or lie-detector testing will be introduced for terrorist offenders freed on licence.

There have been threats to challenge any new restrictions on behalf of those forced to serve longer in jail by bringing a judicial review. However, no such cases are believed to have been lodged in the courts so far.

There is likely to be extra pressure on the Parole Board for more urgent applications from affected inmates.

Shami Chakrabarti, the shadow attorney general, said: “If this is an emergency, it’s an emergency of this government’s making. The emergency is [the state] of the prison system where people come out more dangerous than they go in.

“Unless [this change is] combined with a massive increase in resources it will not work and will be less defensible in legal terms because people will be deprived of even discretionary early release.”