MI5 knew of occasions when two of the men who attacked London Bridge met in the weeks before the atrocity but did not realise what they were planning, an inquest has heard.

The ringleader, Khuram Butt, 27, was under MI5 investigation from 2015 for a suspected desire to stage an attack.

A senior MI5 officer on Wednesday told the inquest into the eight deaths in June 2017 that investigators had material showing that Rachid Redouane, 30, had gone to Butt’s home in March 2017, a visit which was captured on video.

They also knew of a barbecue Butt held in May where Redouane was present and a trip the two men made together out of London.

The witness said Redouane, originally from Morocco, was not identified at the time, but did say MI5 had intelligence in the first half of 2017 linking Butt and a Moroccan man called Rachid as associates who had socialised together on a number of occasions.

The official accepted the security service may have linked Butt to Redouane and the third attacker, Youssef Zaghba, 22, if MI5 had carried out extra inquiries before the attack, but it would have shown them to be friends and not terrorist co-conspirators.

The security chief, known only as witness L, said no intelligence emerged from MI5’s investigation into Butt of attack planning from its extensive surveillance and investigation.

A barrister for the bereaved families had previously accused MI5 and police of missing “opportunities galore” to stop the atrocity.

Jonathan Hough QC, counsel to the inquests, asked: “It might be said … if there had been an effective investigation of Butt with all the tools at MI5’s disposal … it would or should have identified these individuals as significant associates, people worth looking into?”

L replied: “So I believe our investigation could certainly have fully identified Redouane and Zaghba as associates of Butt, but I believe it would only have identified them as social associates rather than significant ones.”

L said Butt’s teaching at Ad-Deen school was a safeguarding issue for the police not MI5, whose prime concern is national security. The school was linked to an alleged extremist, as was a gym in east London where the three men regularly went.

Neither MI5 nor the police worked out which school Butt was teaching at, despite it being less than a mile from his home and him going there most days. The MI5 official said a Google search by the security service did not show the correct school.

Zaghba also taught at the school, and L accepted that the failure to identify the school had deprived MI5 of investigative opportunities.

Hough questioned L about numerous links between the other two attackers and Butt that could have enabled MI5 to identify them, and possibly investigate. These included the fact that:

• They were in regular phone contact with Butt using one of his long-held numbers.

• They met various times at the gym.

• Redouane, Butt and possibly Zaghba regularly swam together on Sundays.

• Redouane and Zaghba occasionally used Butt’s red Corsa.

MI5’s investigation into Butt was suspended twice, in 2016 and again from 21 March to 4 May 2017, weeks before the attacks.

The inquest heard that an MI5 review after the London Bridge attack said its investigation into Butt had been “well and effectively run”.

L said refinements to the way MI5 investigates terrorist suspects introduced after June 2017 would not have made a difference had they been in place at the time.

L told the inquest that MI5 had assessed Butt as posing a “medium risk” of staging an attack on his own, and that while he had aspired to commit violence, he had been thought to have weak capability.

The agency also assessed that Butt, whom they knew from surveillance associated with the extremist preacher Anjem Choudary and who was accessing extremist materials, posed no risk of being a spontaneous violent extremist.

L said this meant someone who “may mount an attack with very little planning or preparation and with very little evidence that there’s a particular trigger to induce them”. Such judgments were “an art rather than a science”.

L also denied that any information had been kept back from counter-terrorism police and their investigation into Butt.

He said a call to the anti-terrorism hotline in September 2015 from Butt’s brother-in-law, warning of increasing extremist behaviour, had not been passed to MI5. L described that as unfortunate, but said it would have made no difference to MI5’s assessment.

The three terrorists ploughed into pedestrians on London Bridge in a van just after 10pm on 3 June 2017, then ran through Borough Market stabbing people.

The assault, which lasted for 10 minutes, only ended when the three attackers charged armed police officers, who shot them dead.

Butt is believed to be the first person to have killed on British soil while under active investigation by MI5 and counter-terrorism police. L said that on the day of the attack, MI5 did not have coverage on Butt, meaning his phone calls were not monitored. He used his phone to hire the van, having first tried to hire a 7.5-tonne lorry.

Those killed in the attack were: Chrissy Archibald, 30, from Canada; Sébastien Bélanger, 36, a chef; Kirsty Boden, 28, a nurse from Australia; Ignacio Echeverría Miralles de Imperial, 39, a Spanish national; James McMullan, 32, who was from Brent, north-west London; Alexandre Pigeard, 26, a French restaurant worker; Xavier Thomas, 45, a French national; and Sara Zelenak, 21, an Australian national.

The London Bridge attack was one of four terrorist atrocities in the UK between March and June 2017.

The inquest continues.