A plumber has been jailed for life for planning a terror attack in Westminster and making bombs for the Taliban.
Khalid Ali, 28, from Edmonton in north London, was arrested on 27 April 2017 in Parliament Street, London, where he was caught carrying three knives.
It was later revealed that he had spent five years in Afghanistan making bombs.
He will serve with a minimum term of 40 years for preparing an act of terrorism in the UK and two counts of possessing an explosive substance with intent.
Judge Nicholas Hilliard QC said that all three convictions were "very grave indeed".
Ali had been "part of a very substantial operation engaged in terrorist activity in Afghanistan", he said.
The judge said the UK plot was designed to attract "maximum publicity and instil terror".
He added: "I am sure your plan was to attack and kill someone in central London.
"Your preparations were complete and you very simply had to identify your precise target and his or her death was very likely to be caused by a knife attack.
"I think you would have killed any police officer you could."
Judge Hilliard passed life sentences with minimum terms of 40 years for the explosives offences, and life with a minimum term of 25 years for planning an attack in the UK - which will run concurrently.
On 22 April last year - one month after the Westminster terror attack - Ali was seen on CCTV walking past a number of high profile locations in central London, including the MI6 building, Westminster Bridge, the Houses of Parliament and Whitehall.
Five days later, his mother called police and said she had found four knives in his bedroom.
He was arrested later that day, just metres from Downing Street.
The court heard how Ali had travelled to Afghanistan in 2011 and spent five years making bombs to maim and kill coalition troops.
He returned to the UK in early November 2016 and was stopped at Heathrow airport, interviewed by police and had his fingerprints and DNA samples taken.
His fingerprints were found on component parts of explosive devices that were handed in to US forces in Afghanistan in 2012.
During police interviews, Ali admitted having "pressed the button" on more than 300 remote controlled bombs in Afghanistan and said he had returned to the UK to deliver a "message" to those in power.
Addressing the judge on Friday, prosecutor Brian Altman QC said the explosives convictions included the "likelihood of multiple deaths being caused", and the preparatory offence relating to Westminster was "a fully-fledged plan nipped in the bud by the authorities".
Police earlier defended the decision not to arrest Ali until April 2017, saying security services had been "managing any potential risk he posed" and that he was arrested at the most appropriate time".