Daniel James (left) was a translator for Gen Sir David Richards
Army interpreter Daniel James, who worked for Britain's top general in Afghanistan, has been found guilty of spying for Iran.
The Iranian-born corporal translated for the head of multi-national forces, General David Richards.
The court heard he sent coded messages to an Iranian military attache in Kabul, saying: "I am at your service".
James, 45, from Brighton, was described in court as a flamboyant fantasist who had invited his boss to salsa dance.
He was found guilty of communicating information to an enemy, the most serious of three charges he faced.
Jurors are still deliberating charges of collecting documents useful to an enemy and wilful misconduct in public office.
'Height of betrayal'
Senior intelligence officers believed that if he had not been arrested his actions could ultimately have cost the lives of UK soldiers and even endangered the security of Britain itself.
Prosecutor Mark Dennis QC said it was "the height of betrayal".
After joining the Territorial Army he was sent to Afghanistan in May 2006, where he worked for Gen David Richards, who has since become head of the British Army.
At the time he headed the Nato-led International Security Assistance Force, a 37-nation coalition comprising 35,000 troops.
James had level one security clearance to move about the base in Kabul and was issued with a "yellow card" detailing General Richards' daily schedule.
James was arrested in December 2006, just two months after he had made contact with Colonel Mohammad Hossein Heydari, an Iranian military assistant based at Tehran's embassy in Kabul.
He began sending the colonel coded e-mails, and told him: "I am at your service," the court heard.
But jurors were told he was arrested before he could become a fully-fledged agent.
James even walked alongside and took pictures of then prime minister Tony Blair when he visited the base.
The court was told James believed he had been passed over for promotion because of jealousy and racism and told a colleague: "They will have their comeuppance."
Prosecutor Mark Dennis QC said: "During the latter part of 2006, the defendant's loyalty to this country wavered and his loyalties turned to Iran, the country of his birth.
"He turned his back on those with whom he was serving in Afghanistan and sought to become an agent for a foreign power."
James was caught "red-handed" by his secret e-mail traffic and was seeking to pass on information useful to insurgents and their backers, Mr Dennis said.
When he was arrested he was found with sensitive documents about troop movements and munitions, stored on a computer memory stick, the jury heard.
They were also told pictures of a Predator spy plane were found in his room.
But James said he remained a loyal British soldier and that those who accused him of being a spy were "mad".
He said the e-mails were part of an attempt to set up a gas deal between Iran and Afghanistan, while the secret documents were given to him to translate.
He worked as a casino croupier, in nightclub security and as a salsa dance instructor before joining the Territorial Army.
The jury has been sent home for the day.