An army corporal who acted as an interpreter for the British commander of Nato forces in Afghanistan was given a 10-year sentence after an Old Bailey judge acknowledged he should never have been appointed to his sensitive position.

Daniel James, who has dual British-Iranian citizenship, was found guilty earlier this month under the Official Secrets Act of trying to spy for Iran. The jury failed to agree on two further charges - one relating to a USB memory stick containing classified Nato documents, the other alleging misconduct in public office.

Yesterday the prosecution said it had decided not to go for a retrial. Handing down James's sentence - five years in custody, five on licence - Mr Justice Roderick Evans said: "The gravest part of your offending and what made this case unique was that you engaged in this activity when you were actually serving in a war zone."

However, the judge said James, 45, was a "ripe target" for the Iranians because of his nationality, disenchantment with the army and "narcissistic" personality. Evans told James: "I accept that you were not the person who approached [the Iranian authorities]. They identified and approached you because of the unique position in which you were placed when you went as a Territorial Army soldier to Afghanistan in 2006."

Evans said James was "all the more ripe" because he was susceptible to an approach. "You have a grossly inflated view of your own importance and your ability. Your counsel has said you should never have been put in the position that you were put in, that you were obviously unsuitable for that position. I have no doubt that there is force in his submission."

The judge also accepted that there had been "no known damage" to British or Nato operations in Afghanistan. But, he added: "The potential for serious harm, had this relationship developed, was immense. There has to be a sentence which is a deterrent."

James was told that he would serve half the term in custody, minus the 709 days he has already been on remand. The judge adjourned a ruling on how much James must have to pay of his legal costs of more than £200,000 to a future date.

Colin Nicholls QC, defending, said the corporal was far from the "John le Carre" or "James Bond" world of spying.

He said: "This is a case of a low ranking Territorial Army soldier who was plucked out of a civilian environment to shoulder a responsibility for which he was clearly unsuitable, as was apparent to many people that he was working amongst and which by reason firstly of his dual nationality and secondly because of his complex narcissistic personality led him to be tempted to commit the offence for which he has been convicted."

Nicholls said James was not given proper security clearance. A psychiatrist had since found he had a narcissistic personality and that he believed he had a "special purpose" to work as a peace maker.

Nicholls said: "He would not be here if the people had been more careful, realising that this man was potential dynamite."

In the three-week trial James presented himself as a patriot and a peacemaker rather than a spy. He enthusiastically recounted his experience as a salsa teacher, body builder and as a Yoruba priest who practised black magic, which he is said to have picked up on one of his regular trips to Cuba.

He flew to Afghanistan in March 2006 after a successful hole in the heart operation. The Ministry of Defence, short of soldiers with knowledge of Dari, widely spoken in Afghanistan, needed his services.

Deputy Assistant Commissioner John McDowall, head of Scotland Yard's counter terrorism command, said: "Daniel James was in a trusted position. He betrayed that trust. He was willing to pass on sensitive information which could have been used against British or coalition troops."