In the environment of a high security Old Bailey courtroom, a senior MI5 officer offered his “profound personal sympathies” to the families of the eight victims of the London Bridge terror attack as he gave evidence at the inquest into their deaths.

But the man identifiable only as Witness L stopped short of making a full apology, arguing that while every member of MI5 “comes to work every day to stop attacks like this”, unfortunately some terrorists slipped through the net.

“We know we cannot stop them all, as we failed to stop this one,” Witness L declared, his voice emerging from behind a green curtain in the dock. “But it’s our job to try to squeeze the maximum learning out of it.”

It was a key moment in his two days of evidence, where the agent was repeatedly pressed as to how Khuram Butt and two associates were able to carry out the frenzied knife attack on a Saturday evening in the capital in June 2017.

Butt had been one of MI5’s 3,000 “subjects of interest” since mid-2015. The Londoner’s involvement in the terror attack at London Bridge is the first time such a person had been able to slip through the agency’s net.

A string of examples emerged of how important pieces of information about Butt were not collected or not fully appreciated. However, almost every time Witness L said they would not have made any difference.

At one point in 2016, police had found a video on Butt’s laptop of him clutching a knife and slitting the throat of a cow after he had been arrested on fraud charges in 2016, which he compared to the massacre of 600 Jewish men and shared with MI5.

Yet, it was not sufficiently significant to give rise to alarm, Witness L said, adding: “I think that’s a very strong interpretation of that particular piece of video.”

Critically, MI5’s investigators did not grasp Butt’s growing association with the other two attackers: Rachid Redouane and Youssef Zaghba, which developed at the Ummah Fitness Centre in Barking, east London. Consideration was given to further coverage of the gym, but it was never targeted for investigation.

As a result neither Redouane or Zaghba were known to the security service at the time of the attack. Yet, Witness L said, even if MI5 had picked up the connections the agency would only have assumed they were “purely social contacts” – not would-be plotters.

Butt was assumed to be acting in isolation and was twice assessed as such. The second assessment, in May 2017 – two weeks before the attack – concluded he was an “unresolved risk”, yet at the same time consideration was given to ending the investigation.

MI5 is “the largest it has ever been in its 110-year history” according to Witness L. But it did not have the resources to keep a close eye on Butt; he was not, for example, under surveillance when he tried to hire a truck (although he only got a van) on the day of the attack itself.

In fact, the agency’s investigation into Butt had to be suspended twice in the spring of 2016 and 2017.

The first time, Witness L said, was because of the “broader pressure” in the aftermath of the Paris attacks. The second time, between 21 March (a day before the Westminster attack) and 4 May 2017, was because of a wider “unprecedented level of threat which we were facing”.

Witness L observed that if the public felt that terrorist attacks like this had be avoided at all cost, then something different would be required, such as “a wider conversation about how large the security service should be,” he said.