Former soldier Daniel Khalife was “devastated” to be told his Iranian heritage could prevent him from working in army intelligence, his trial has heard.

Giving evidence at Woolwich Crown Court, the 23-year-old told the jury he believed he could “utilise” his background to “further national security” and “wanted my country to understand that”.

Khalife told jurors he was 17 years old when a troop commander said having an Iranian mother meant he would not pass the required security vetting.

“I was quite devastated,” the former Royal Corps of Signals soldier said. “I really was at a loss at what to do.”

Asked by his barrister Gul Nawaz Hussain KC if he would have made the same decisions later on had he been offered more support from his army superiors, Khalife replied: “No.”

The former soldier – who reiterated that he is a “patriot” – said he believed his Iranian heritage could be useful to the intelligence community, and came up with his plan to work as a double agent a month later.

He told the court: “I believed I could utilise my background … I wanted to utilise my background to further our national security.

“I wanted my country to understand that.”

Khalife told jurors he was reading a news article about American sanctions imposed on Iranians – including a man called Hamed Ghashghavi – when he came up with the idea.

He later contacted Mr Ghashghavi by sending him a Facebook message, the court heard.

“I understand this plan might sound outlandish,” he said.

The court was shown a notebook in which he had outlined plans for “spying”, and to contact the Iranians and then the USA.

Eventually, he was put in touch with Iranian intelligence officers.

“They viewed me as just a young boy and I could tell … they were trying to groom me and build a rapport with me,” he said.

Earlier on Wednesday, the former soldier said he visited Iran as a 15-year-old and “thought it was a horrible place”.

He was taken to the country for four weeks by his “very strict” mother to show him how people lived there, his trial heard.

“It’s a tragedy what’s happened to that country,” he added.

Khalife, who began his evidence by saying “good morning” to jurors, told the court he was “still a boy” when he joined the military, adding there had been a “major shift” in his maturity since being held in custody.

“I’ve done a significant amount of growing up,” he continued.

Khalife, who was born in the Marylebone area of London before moving to Richmond, told jurors his mother was born in Iran.

Asked by about his mother’s feelings towards the country now, he said: “To this day I don’t think I’ve met one person who lives outside of Iran who is not hostile to the government.

“My mother detests the regime, probably the country as well.

“Me and my family are against the regime in Iran.”

Khalife said he had had very little contact with his Lebanese father, who would “pop in and out, do some damage and then leave”.

The former soldier is alleged to have fled his army barracks in January 2023 when he realised he would face criminal charges over allegations he passed classified information to Iran’s intelligence service.

Later, while on remand, he is alleged to have escaped from HMP Wandsworth in September 2023 by tying himself to the underside of a food delivery truck using bedsheets.

As well as the prison escape, he also faces charges contrary to the Official Secrets Act and Terrorism Act, and is accused of perpetrating a bomb hoax.

He denies all the charges, and the trial continues.