A total of 31 late-stage terror plots have been foiled in the UK in the past four years, the head of MI5 has said.
Director general Ken McCallum, who revealed in October there had been 27 attacks thwarted since 2017, said there had been six during the pandemic.
He said they were largely Islamic extremist plots, but a "growing number" were planned by right-wing terrorists.
He also warned that the fall of Afghanistan to the Taliban was likely to have "emboldened" UK terrorists.
The terror threat would not change overnight but there could be a "morale boost" for extremists, he said. "The terrorist threat to the UK, I am sorry to say, is a real and enduring thing."
"Of course there are likely to be terrorist attacks on UK soil on my watch," he said, saying MI5 works as hard as it can to stop them happening but "to our horror, we know that won't be possible on every single occasion".
The head of the security service added that MI5 had "saved thousands of lives across the last 20 years" but it "cannot always succeed".
Mr McCallum, speaking to BBC Radio 4's Today programme on the eve of the 20th anniversary of the 9/11 attacks on the US, said that smaller-scale terrorist acts by those already in the UK made up the largest number of threats faced by MI5.
"There is no doubt that events in Afghanistan will have heartened and emboldened some of those extremists and so being vigilant to precisely those kinds of risks is what my organisation is focused on along with a range of other threats," he said.
But there is still also a risk of an increase in larger plots directed by terrorism groups like al-Qaeda, he warned.
"The big concern flowing from Afghanistan alongside the immediate inspirational effect is the risk that terrorists reconstitute and once again pose us more in the way of well-developed, sophisticated plots of the sort that we faced in 9/11 and the years thereafter," Mr McCallum said.
While the government says it will judge the Taliban by their actions, the UK security service would plan for the possibility "more risk, progressively, may flow our way", Mr McCallum said.
"Terrorist threats tend not to change overnight in the sense of directed plotting or training camps or infrastructure - the sorts of things that al-Qaeda enjoyed in Afghanistan at the time of 9/11," he said.
"These things do inherently take time to build, and the 20-year effort to reduce the terrorist threat from Afghanistan has been largely successful.
"But what does happen overnight, even though those directed plots and centrally organised bits of terrorism take a bit longer to rebuild... overnight, you can have a psychological boost, a morale boost to extremists already here, or in other countries."
It is difficult to say if the UK is safer, or less safe, now than it was at the time of the September 11 attacks, said Mr McCallum.
So-called Islamic State had "managed to do something that al-Qaeda did not" in inspiring lots of people to attempt smaller scale acts of terrorism, he explained.
He added: "We need to be vigilant both for the increase in inspired terrorism which has become a real trend for us to deal with over the last five to 10 years, alongside the potential regrowth of al Qaeda-style directed plots."
For the past two decades, terrorism has dominated MI5's work. But with significant shifts over time.
It took the attacks of 7 July 2005 for it to fully understand the threat came from within as well as abroad. By the 10th anniversary of 9/11, the sense was that the threat from al-Qaeda might be receding and MI5 could turn to other issues of concern, such as state espionage.
But then the Islamic State group emerged out of Iraq and Syria and a new wave started - less sophisticated and organised but still deadly.
Once again, in the last couple of years, there was a hope that this jihadist threat might be slowing as MI5 took on extreme-right wing activity and focused more on Russia and China.
But recent events have raised concerns that the jihadist threat could evolve once again, with Afghanistan inspiring people to act, or by the Western withdrawal creating a new safe haven for groups to operate in and plan more sophisticated attacks, as they did in the years around 9/11.
Former chief of the UK defence staff General Lord Richards said he believes we are closer to "another 9/11" following the US and UK's withdrawal from Afghanistan.
"I fear the Taliban and some extremist jihadist groups are, whatever they like to say, in each other's pockets," he told LBC. "Scores will be settled, debts will have to be repaid and there will be ungoverned space opened up in Afghanistan which those groups will exploit and the ability of the Taliban to actually manage them will be minimal."
Tony Blair, Labour prime minister at the time of the 9/11 attacks, told Today: "We need to decide whether this radical Islamist threat is a real first-order security threat or not. If it is, we need to combine the leading powers of the world and we've got to construct a long-term strategy where we have the staying power to see it through and to defeat them."
He said the Taliban "need to know they're going to be held to account - they need to know that if they go back to sheltering terrorist groups that are coming after us then we are prepared to act against them".