Updated

The trial of a British Army interpreter accused of spying for Iran began Monday with prosecutors alleging he was a fantasist who believed he had been passed over for promotion and was the victim of racism.

Prosecutors said that Cpl. Daniel James — who was working as a translator for former Gen. David Richards, the NATO commander in Afghanistan — sent a coded message to an Iranian military attache in Kabul which ended with the phrase, "I am at your service."

"The defendant's loyalty to this country wavered and his loyalties turned to Iran, the country of his birth," prosecutor Mark Dennis told a jury at London's Old Bailey court. "He turned his back on those with whom he was serving in Afghanistan and sought to become an agent for a foreign power."

James, 45, denies communicating information useful to an enemy and collecting the information — two NATO situation reports — on a USB memory device. He also denies willful misconduct in public office.

James was born was born Esmail Mohammed Beigi Gamasai in Iran and moved as a teenager to Britain, where he later changed his name and became a citizen.

He joined the British reserves in 1987, and was called up to serve a tour in Afghanistan in March 2006. Two months later, he was appointed translator for Richards, who was then the overall commander of the International Security Assistance Force in Afghanistan.

"This assignment gave the defendant a very trusted and sensitive position," Dennis said in his opening statement, adding that James was "something of a Walter Mitty character." The description refers to a character who fantasized about being a hero in a story by the late American author James Thurber.

In an interview with police after his arrest in December 2006, James complained about his lack of promotion and officers who he said were racist and impeded his progress, the prosecutor said.

Dennis said James sent coded messages to an Iranian military assistant based at Tehran's embassy in Kabul. It wasn't clear if James was attempting to audition for a position as an agent or if he'd already been accepted, the prosecutor said.

"The concern is not so much the actual damage done by the known disclosure of information, but in the potential damage that could have occurred if his activities had not been curtailed by his early detection and arrest," Dennis said.

The trial is expected to last three or four weeks. Some portions are expected to be heard in secret.