Emergency legislation will be introduced to end the automatic early release from prison of terror offenders, the government has said.
Justice Secretary Robert Buckland told MPs the change would apply to both current and future offenders.
Terror offenders will only be considered for release once they have served two-thirds of their sentence and with the approval of the Parole Board.
It follows two attacks by men convicted of terror offences in recent months.
On Sunday, Sudesh Amman, 20, was shot dead by police in Streatham, south London, after stabbing two people. And in November two people were killed near London Bridge by Usman Khan.
Amman was released from prison towards the end of January, while Khan was out on licence from prison when he launched his attack in central London.
Mr Buckland said the latest attack made the case "for immediate action".
"We cannot have the situation, as we saw tragically in yesterday's case, where an offender - a known risk to innocent members of the public - is released early by automatic process of law without any oversight by the Parole Board," he said.
He said the new legislation would mean people convicted of terrorism offences will no longer be released automatically after they have served half of their sentence.
Because we face "an unprecedented situation of severe gravity", the legislation will also apply to serving prisoners, Mr Buckland said.
The Ministry of Justice said the legislation would be introduced "when parliamentary time allows".
The government will also consider making new legislation to ensure that extremists are more closely monitored on release and will review whether the current maximum sentences for terrorist offences are sufficient.
The Parole Board for England and Wales has welcomed the plans.
In a statement, it said it would not "direct the release of an offender unless [it is] satisfied, taking account of all the evidence, that detention is no longer necessary for the protection of the public".
"The board's focus is rightly on those who have committed the most serious criminal offences and it is vital that the most serious offenders are subject to a proper assessment before their release," it added.
However, human rights group Liberty described the government's actions after recent terror attacks as a "cause of increasing concern for our civil liberties".
'System is in chaos'
Clare Collier, an advocacy director for the campaign group, said: "From last month's knee-jerk lie detector proposal, to today's threat to break the law by changing people's sentences retrospectively, continuing to introduce measures without review or evidence is dangerous and will create more problems than it solves.
"It's clear the UK's counter-terror system is in chaos and desperately needs proper scrutiny and review."
Responding to the government announcement in the Commons, shadow justice secretary Richard Burgon said the justice system was in "crisis" due to funding cuts.
"The government cannot use sentencing as a way of distracting from their record of bringing the criminal justice system to breaking point," he said.
Former government counter-terrorism adviser Professor Ian Acheson argued that there might be instances where offenders should stay in prison.
He told BBC News: "There will be some people for whom their ideology is bulletproof and there is no way we can get inside that.
"If there are people who are absolutely determined not to accept any intervention that will change that toxic mind-set, yes they should be in prison and if necessary, indefinitely."
Although plans for the Parole Board to decide if people convicted of terrorism offences should be released after serving two thirds of their sentence were in the Queen's Speech, there were no proposals at that stage for the measures to apply retrospectively.
All that changed after the Streatham attack - the third incident involving convicted Islamist extremists in two months.
Ministers are clearly concerned about the risks posed by other prisoners serving sentences for terrorism who are due to be let out: there's about one release, on average, every week.
But the measures, if approved by Parliament, will almost certainly be the subject of a challenge in the courts. Is it fair that a prisoner who's been convicted and sentenced under one set of rules suddenly finds themselves locked up for longer under a different set of rules?
The government is likely to justify its approach on the grounds of national security, so prepare for an epic legal battle that may well end up at the Supreme Court.
Amman was shot dead on Streatham High Road on Sunday afternoon after stabbing two people in what police called an Islamist-related terrorist incident. He wore an imitation suicide belt.
He had been released from prison about a week ago after serving half of a sentence for terror offences, and was under police surveillance.
Armed officers were following Amman on foot as part of a "proactive counter-terrorism surveillance operation", Scotland Yard said.
He was seen entering a shop in Streatham High Road shortly before 14:00 GMT, where he is believed to have stolen a knife. Once outside the shop he attacked two people.
In a statement on Monday, the Metropolitan Police said its officers responded within 60 seconds of Amman's attack, fatally shooting him.
The force did not reveal more details about its surveillance operation on the terror convict.
Three people were taken to hospitals, including the two stabbing victims.
One victim, a man in his 40s, is now said to be recovering after sustaining injuries that were initially thought to be life-threatening. Another, a woman in her 50s, has been discharged from hospital.
A third woman in her 20s suffered minor injuries, thought to have been caused by broken glass from the gunfire.
The attack comes after convicted terrorist Khan fatally stabbed Saskia Jones and Jack Merritt at Fishmongers' Hall near London Bridge on 29 November last year.
Khan had been released from jail on licence in 2018, half-way through a 16-year sentence for terrorism offences.
This prompted a raft of measures to be proposed by the Home Office in January.
The so-called Counter-Terrorism Bill would also ensure people convicted of serious offences, such as preparing acts of terrorism or directing a terrorist organisation, spend a minimum of 14 years in prison.
There are currently at least 74 people who were jailed for terror offences and subsequently freed on licence.
There are also 224 people convicted of terrorism offences in prison in Great Britain, most of whom must be released at the end of their custodial sentence.