An al Qaida bomb-maker who plotted a knife attack on MPs and police outside the Houses of Parliament has been handed three life sentences with a minimum term of 40 years.

Khalid Ali, 28, had three knives when he was arrested by armed police in Parliament Square last April following surveillance by counter-terrorism police.

The plumber had been in the sights of police since he returned from Afghanistan, where he spent five years making Taliban bombs used to maim and kill coalition troops.

In late 2016, the FBI in the United States matched his fingerprints to those on two caches of explosives recovered in 2012.

Khalid Ali court case
One of the knives that was retrieved from Khalid Ali when he was detained (Met Police/PA)

Following an Old Bailey trial in June, Ali was found guilty of preparing terrorist acts in Britain and two charges of possessing explosive substances with intent abroad.

Sentencing, Judge Nicholas Hilliard QC handed Ali three life sentences.

He gave a minimum of 40 years for making IEDs for the Taliban in 2012 and 25 years for the plot to kill in Britain and attract “maximum publicity and instil terror”.

He said: “I am absolutely sure you were in Afghanistan. You were a valued member of a team making IEDs that were detonated in combat between January and July 2012.”

“I have no doubt whatsoever that there is a very considerable risk of your committing offences of violence in the future and cause death or serious injury as a result.

“I’m 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. You would kill any police officer you could.”

Khalid Ali court case
Armed police arrested Khalid Ali in Whitehall, London (Dominic Lipinski/PA)

The court heard Ali’s family in Edmonton, north London, reported him missing in June 2011 after he disappeared without warning.

He resurfaced at the British Consulate in Turkey more than five years later, claiming he had lost his passport.

In November 2016, the loyal Taliban and al Qaida follower, was stopped at Heathrow airport, interviewed by police and his fingerprints and DNA samples were taken.

He told officers he had been involved in a Road to Hope convoy to Palestine in 2010 and then went to Pakistan after MI5 had tried to recruit him as a “James Bond” type spy.

In late 2016, Ali’s DNA and fingerprints were shared with the FBI agents and 42 prints linked him to two loads of IEDs found in Afghanistan in 2012.

Meanwhile, he had resolved to carry out an attack on Westminster to “send a message” to British authorities, jurors were told.

On March 18, he carried out reconnaissance under the cover of a Stand Up To Racism march, which took him past Downing Street and the Cenotaph.

Khalid Ali court case
Detonators were used in bomb making in Afghanistan by British fighter Khalid Ali (Met Police/PA)

On April 22, he was caught on CCTV walking past the MI6 building at Vauxhall Cross, as well as Westminster Bridge, the Houses of Parliament and Whitehall.

Just after midnight on April 27, his mother called police, saying she had found four knives in her son’s bedroom and she was scared he was going to kill the family.

The court heard that Ali had bought the blades two days before at The Mighty Pound in Ealing, west London, and had been seen by surveillance officers to throw away the packaging.

After leaving his mother’s home, Ali went to Ealing, where he set about rearming himself with an 8in chef’s knife and two 3.4in paring blades from Wilko, also purchasing kitchen utensils including a potato masher as cover.

He also bought a rucksack with a Union flag and London logo on it, before travelling by Tube to carry out his attack, which came just four weeks after the Westminster Bridge killings.

He deliberately dropped his mobile phone into the Thames, but it was later recovered by police divers.

When armed police moved in to arrest Ali, the knives were seized from his jacket pockets and the waistband of his tracksuit bottoms.

In police interview, Ali said he wanted to deliver a “message” to British authorities, but claimed the knives were for protection.

He admitted involvement in IEDs in Afghanistan, even bragging he detonated more than 300 devices, although he later backtracked.