A senior British spy testified Monday that the ringleader of the 2005 suicide attacks and his No. 2 were on MI5's radar for more than a year before the bombings but it wasn't clear an attack was imminent. The suicide bombings — Western Europe's first — killed 52 people.

MI5, Britain's domestic intelligence agency, fought to prevent its staff being questioned in public at the inquest into the bombings. But presiding Judge Heather Hallett said victims' families had the right to know whether the attacks could have been prevented.

Reporters were only allowed to hear — not see — the MI5 witness identified only as 'Witness G,' who has been a member of MI5 since 1991. At the time of the bombings, he was a senior manager working in international counterterrorism operations.

He testified Monday it wasn't clear that bombers Mohammed Sidique Khan or Shehzad Tanweer were planning an imminent attack before the July bombings. He also said it was difficult to determine when or if terror suspects moved from supporting terrorism to actually planning an attack.

In April 2004, an al-Qaida informant alerted MI5 that two men called 'Ibrahim' and 'Zubair' had traveled to a terrorist training camp in Pakistan in 2003. In August 2004, the informant was then shown surveillance pictures of Khan and other bomber, Shehzad Tanweer, but he failed to identify them.

Khan and Tanweer were being watched because of their ties to other terror suspects.

Then, just months before the July 2005 attacks, MI5 received another tip about an extremist called "Saddique" who had spent two months training after traveling to Pakistan in 2001. But the name was common and it wouldn't have necessarily raised alarm bells, the witness said.

"With a common name, as this one would be for us, any software which picks up any reference to it would be likely to come up with all sorts of other Sidique Khans," he said. While software has improved, "it's still a long way from perfect on common names."

Although Khan's communications had been bugged in early 2004 when he discussed traveling to Pakistan with fertilizer bomb plotter Omar Khyam, police only established it was Khan's voice on the tape after the July 7 attacks. Khyam and four others were convicted in 2007 of plotting attacks against a construction firm, utilities or London's Ministry of Sound nightclub using fertilizer-packed explosives.

The MI5 witness said a fertilizer bomb plot linked with Khyam was considered a higher priority at the time.

Amid the fertilizer bomb plot investigation, MI5 also began to look at associates of the fertilizer bomb plotters, but there were some 4,000, the MI5 officer said.

There was one main MI5 officer to investigate all of these contacts, but the officer was also responsible for "other work going on at the time," the MI5 agent said.

Although the MI5 officer, who is chief of staff to MI5 Director General Jonathan Evans, rejected claims that there had been significant intelligence failings, he said lessons had been learned since the 2005 attacks.

Britain's intelligence agencies of MI5, MI6 and GCHQ — Britain's eavesdropping agency — have received considerable funding boosts since the attacks.

The attacks, carried out by Khan, 30; Tanweer, 22; Hasib Hussain, 18; and Jermaine Lindsay, 19, killed 52 people and injured more than 700 when the bombers targeted trains and buses during morning rush hour.

The inquest into the attacks began in October and is due to finish next month.