The soldier, named simply Mahmood, 22, said that in May he told the insurgents of his plan to shoot Americans the next time they visited the outpost where he was based in northeastern Afghanistan. He asked the Taliban to take him in if he escaped.
The Taliban veterans he contacted were skeptical. Despite their public insistence that they employ vast ranks of infiltrators within the Afghan army and the police, in interviews conducted by phone and through written questions they acknowledged that many of the insider attacks they take credit for start as offers by angry young men like Mahmood.
They had seen many fail, or lose their nerve before even starting, and they figured that Mahmood, too, would prove more talk than action or would die in the attempt.
"Even the Taliban didn't think I would be able to do this," Mahmood said in an interview.
He proved them wrong days later, on the morning of May 11, when he opened fire on American trainers who had gone to the outpost in the mountains of Kunar province. One American was killed and two others were wounded. Mahmood escaped in the ensuing confusion, and he remains free in Kunar after the Taliban welcomed him into their ranks.
It was, he said, his "proudest day."
Such insider attacks, by Afghan security forces on their Western allies, became "the signature violence of 2012," in the words of one former U.S. official. The surge in attacks has provided the clearest sign yet that Afghan resentment of foreigners is becoming unmanageable, and U.S. officials have expressed worries about its disruptive effects on the training mission that is the core of the U.S. withdrawal plan for 2014.
"It's a game changer on all levels," said 1st Sgt. Joseph Hissong, an American who helped fight off an insider attack by Afghan soldiers that left two men in his unit dead.
Cultural clashes have contributed to some of the insider attacks, with Afghan soldiers and police officers becoming enraged by what they see as rude and abusive behavior by Americans close to them. In some cases, the abusive or corrupt behavior of Afghan officers prompts the killer to go after Americans, who are seen as backing the local commanders. On rare occasions, like the killing of a U.S. contractor by an Afghan policewoman late last month, there seems to be no logical explanation.
But behind it all, many senior coalition and Afghan officials are now concluding that after nearly 12 years of war, the view of foreigners held by many Afghans has come to mirror that of the Taliban. Hope has turned into hatred, and some will find a reason to act on those feelings.
"A great percentage of the insider attacks have the enemy narrative - the narrative that the infidels have to be driven out - somewhere inside of them, but they aren't directed by the enemy," said a senior coalition officer, who asked not to be identified because of Afghan and U.S. sensitivities about the attacks.
The result is that, although the Taliban have successfully infiltrated the security forces before, they do not always have to. Soldiers and police officers will instead go to them, as was the case with Mahmood, who offered a glimpse into the thinking behind the violence in one of the few interviews conducted with Afghans who have committed insider attacks.
"I have intimate friends in the army who have the same opinion as I do," Mahmood said. "We used to sit and share our hearts' tales." But he said he did not tell any of his compatriots of his plan to shoot Americans, fearing that it could leak out and derail his attack.
The interviews with Mahmood and his Taliban contacts were conducted in recent weeks by telephone and through written responses to questions. There are also two videos that show Mahmood with the Taliban: an insurgent-produced propaganda video available on jihadist websites, and an interview conducted by a local journalist in Kunar.
Though Mahmood at times contradicted himself, falling into stock Taliban rhetoric about how it had always been his ambition to kill foreigners, much of what he said mirrored the timelines and versions of events provided by Taliban fighters who know him, as well as Afghan officials familiar with his case.
Mahmood grew up in Tajikan, a small village in the southern province of Helmand. The area around his village remains dominated by the Taliban despite advances against the insurgents made in recent years by U.S. and British troops. Even Afghans from other parts of Helmand are hesitant to travel to Tajikan for fear of the Taliban.
Col. Khudiadad, an Afghan officer who runs the Afghan National Army's recruitment center in Helmand, said Mahmood enlisted about four years ago. His story, up to that point, would be familiar to many Americans: He was a poor boy from a family of eight who was sweeping up in a tailor shop and looking for a better life. The army offered steady pay, reading and writing lessons, and a chance to see something beyond the mud hovels in which he was born and raised.
"He barely had a beard," Khudiadad, who also uses only one name, recalled in an interview. "He looked so innocent that you wouldn't believe what he did if you only saw him then."
Mahmood says he was anything but an innocent. He grew up being told that Americans, Britons and Jews "are the enemies of our country and our religion," he said.
Until May, he worked and fought alongside foreigners without incident. The change came in the Ghaziabad district of Kunar, where he ended up after the start of 2012, he said.
The area is thick with Taliban, along with Islamists from Pakistan. Many residents sympathized with the insurgents and often complained to Afghan soldiers about the abuses committed by Americans and the failure of Afghan soldiers to control much of anything beyond the perimeter of their own outpost, Mahmood said. The Taliban, they glorified.
Listening to villagers, Mahmood became convinced that the foreigners had killed too many Afghans and insulted the Prophet Muhammad too many times. He wanted to be driving them out, not helping them stay. The villagers' stories "strengthened my desire to kill Americans with my own fingers," he said.
He contacted the Taliban through a local sympathizer. He did not want help - he only asked the insurgents "not to shoot me" if he managed to escape after attacking the Americans, which he told them would happen in a few days.
He was on guard duty when U.S. soldiers arrived at the outpost on May 11. He waited for a few of them to shed their body armor and put down their weapons, and then he opened fire. (New regulations require U.S. trainers to keep their armor on and weapons at hand when visiting Afghan bases.)
The Afghan and American soldiers initially thought the attack was coming from the outside. They "didn't even think that someone within the Afghan army might have opened fire on Americans," he said. "I took advantage of this confusion and fled."
He claimed to have hit six Americans. "I don't know how many were killed, though I hope all were," he said. The coalition said one soldier was killed and two were wounded.
The Taliban welcomed him as a hero. He was given the title "ghazi," an honorific for someone who helps drive off non-Muslim invaders. "They let me keep the same rifle I used to kill Americans."
In August, the Taliban featured Mahmood in a propaganda video, calling him "Ghazi of Ghaziabad." The video shows Mahmood, smiling broadly, being draped with garlands and showered with praise from local elders, Taliban fighters and cheering crowds of men and boys.
The following month, the U.S.-led military coalition announced that it had killed Mahmood in an airstrike. The coalition now says it was mistaken and that Mahmood is still with the Taliban in Kunar.
Villagers and officials in Helmand backed up that account, saying Mahmood had been in touch with relatives since the report of his death. Mahmood said he spoke only to his mother, and that "she was happy."