LONDON — A former British soldier whose audacious escape from a London prison spurred a dayslong search was convicted on Thursday of spying for Iran.

Daniel Khalife, 23, was found guilty by a jury in Woolwich Crown Court on violations of Britain’s Official Secrets Act and Terrorism Act by collecting information useful to an enemy — Iran. He was cleared of a charge of planting fake bombs in his military barracks.

Prosecutors said Khalife played a “cynical game” by claiming he wanted to be a spy after he had delivered a large amount of restricted and classified material to the Iranian intelligence service, including the names of special forces officers.

Khalife testified that he had been in touch with people in the Iranian government but that it was all part of a ploy to ultimately work as a double agent for Britain, a scheme he developed from watching the TV show “Homeland.”

“I wanted to utilize my background to further our national security,” he told jurors.

Defence lawyer Gul Nawaz Hussein said Khalife’s aspirations to be a James Bond figure were naive, stupid and bordered on slapstick. He said his client was more “Scooby Doo” than “007.”

Despite what seemed like amateurish bumbling, Cmdr. Dominic Murphy, head of counter terrorism at the Metropolitan Police, said Khalife presented a danger.

“He’s the ultimate Walter Mitty character who was having a significant impact in the real world,” Murphy said, referring to the fictional character in a James Thurber short story about a meek proofreader who daydreams of daring escapades.

“We know very well the threat that Iranians pose to the U.K.’s national security” Murphy said, noting that 20 plots, including assassination plans, had been disrupted by U.K. authorities.

Khalife’s court case had not received much attention until he escaped from a London prison in September 2023 and went on the run for three days.

Khalife was working in the kitchen in Wandsworth Prison, in south London, when he strapped himself to the bottom of a delivery truck and got a lift to freedom. He was ultimately nabbed on a canal path after a massive search.

The escape from the Victorian-era prison exposed much broader weaknesses with the nation’s aging and overcrowded correctional system. An inquiry is currently underway into how Khalife was able to escape and whether others helped.

During his trial, Khalife pleaded guilty to the escape, but continued to contest the spying charges.

Justice Bobbie Cheema-Grubb said Khalife faces “a long custodial sentence” when he is sentenced after the New Year.

Khalife joined the Army at 16 and was assigned to the Royal Corps of Signals, a communications unit that is deployed with battlefield troops, as well as special forces and intelligence squads.

He was told he could not join the intelligence service because his mother is from Iran.

At 17, he reached out to a man connected with Iranian intelligence and began passing along information, prosecutors said. He was given NATO secret security clearance when he took part in a joint exercise at Fort Cavazos in Texas in early 2021.

British security officials were not aware of Khalife’s contacts with the Iranians until he contacted MI6, the U.K.’s foreign intelligence service, to offer to work as a double agent.

He reached out to MI6 anonymously, saying he had earned the trust of his Iranian handlers and that they had rewarded him by leaving $2,000 cash ($1,578 pounds) in a dog poo bag in a north London park.

Khalife said most of the material he provided to his Iranian handlers was information he made up or data available online and didn’t expose military secrets.

But prosecutors said some of the army documents were genuine and they used evidence from Khalife’s mobile phones, notes he wrote to himself and surveillance footage to show he gathered and shared classified information. They also found he traveled to Turkey to meet a contact.

“He surreptitiously sought out and obtained copies of secret and sensitive information which he knew were protected and passed these on to individuals he believed to be acting on behalf of the Iranian state,” said Bethan David of the Crown Prosecution Service. “The sharing of the information could have exposed military personnel to serious harm, or a risk to life, and prejudiced the safety and security of the United Kingdom.”