Image copyright Metropolitan Police

MI5 closed a file on the Westminster Bridge attacker five years before he struck despite knowing he had been in contact with a convicted terrorist.

A senior official from the Security Service denied MI5 had missed a series of opportunities to launch a fuller investigation into Khalid Masood.

He told an inquest MI5's decision to no longer consider Masood a threat to national security was "sound".

Masood killed four pedestrians and a police officer in March 2017.

The inquest into the victims' deaths is taking place at the Old Bailey in London.

Kurt Cochran, 54, Leslie Rhodes, 75, Aysha Frade, 44, and Andreea Cristea, 31, were killed when Masood drove an SUV into them on Westminster Bridge.

PC Keith Palmer was stabbed to death while on duty outside Parliament.

Speaking for the first time about what MI5 knew, a senior official known only as Witness L was shielded from the court by a green curtain.

Only court transcription staff were allowed to use electronic devices while he gave his evidence.

He told the court that in 2004, a mobile number for Masood was found in the contacts list of Waheed Mahmood, who was later jailed for life for his part in the UK's then-biggest bomb plot.

Image copyright Metropolitan Police Image caption Waheed Mahmood was convicted for his part in a bomb plot which police said could have killed hundreds of people

MI5 said they did not know it was Masood's number until later, although they said there was no effort to find out whose number it was at the time.

Subsequent investigations found no intelligence he was planning his own attack and Masood's status was downgraded in 2010. MI5 stopped investigating him at the end of that year, and closed the file in 2012.

Between 2010 and 2016 MI5 received intelligence that he was associating with people who were being actively investigated - including some who were members of the banned al-Muhajiroun terror network.

MI5 also had intelligence he was consuming extremist material and, in 2013, heard he had praised the 9/11 attacks on the World Trade Centre.

Witness L told the court: "None of these indicators were enough to say that he was involved in activities of significant concern to us."

'Logical to close file'

Counsel to the inquest, Jonathan Hough QC, read from a written statement by Witness L that said: "We have reviewed the decision to close Masood (as a person of interest) with the benefit of hindsight and we conclude the decision was sound."

The officer went on: "It was logical, necessary and proportionate to consider him a closure."

The witness confirmed that Masood was considered to be an extremist but said "we had satisfied ourselves he was not involved in attack planning or facilitation".

He said MI5 had received intelligence Masood had consumed extremist material, but "nothing that would reach the threshold for prosecution".

Witness L said that, after 2010, Masood had associated with a "small number" of people who were under active investigation by MI5.

Gareth Patterson QC, representing some of the families of Masood's victims, said MI5 could have delved deeper - but Witness L said his officers couldn't chase every extremist they came across.

He said: "There simply wasn't enough intelligence for us to work on that would have allowed us to identify his plot and work with the police to frustrate it."

He offered his profound sympathies to the victims of the attack, adding that "everyone in my service comes to work every day to stop attacks".