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.
It was only after the young Afghan soldier's hatred of Americans had grown murderous that he reached out to the Taliban.
The soldier, named simply Mahmood, 22, says 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 police forces, in interviews conducted by phone and written-out questions they acknowledged that many of the insider attacks they take responsibility 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 his 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 U.S. trainers who had come to the outpost in the mountains of Kunar Province. One American was killed and two others 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 a former American official. The surge in attacks has provided the clearest sign yet that Afghan resentment of foreigners is becoming unmanageable. In turn, that threatens the foundation of the U.S. plan for withdrawal by the end of 2014, which relies heavily on the direct training of the Afghan forces by Western advisers.
"It's a game changer on all levels," said First 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 policemen 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, or his countrymen. 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 many senior coalition and Afghan officials are now concluding that behind it all, 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 spoke on the condition of anonymity because of Afghan 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 come 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 last year with Afghans who have committed insider attacks.
The interview with Mahmood and his Taliban compatriots was conducted in recent weeks by phone and through written responses to questions. The New York Times also viewed two videos of Mahmood with the Taliban -- an insurgent-produced propaganda video readily available on jihadist Web sites 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 lined up with the timelines and versions of events provided by Taliban fighters who know him and by Afghan officials familiar with his case.
He grew up in Tajikan, a village in Helmand Province, in the south. 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 army's recruitment center in Helmand, said Mahmood had joined the Afghan National Army about four years ago, when he was 18. 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, a chance to see something beyond the mud hovels in which he was born and raised.
"He barely had a beard," Colonel 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."
Today, Mahmood says he was anything but an innocent. He grew up being told that Americans, Britons and Jews were "the enemies of our country and our religion," he said.
But until May, he worked and fought alongside foreigners without incident. The change came in Ghaziabad District of Kunar, where he ended up after the start of the year, he said.
The area is thick with Taliban, along with Islamists from Pakistan. Many locals sympathized with the insurgents and often complained to the Afghan soldiers about the abuses committed by Americans and the failures of Afghan soldiers to control much beyond the perimeter of their own outpost, Mahmood said. The Taliban, they glorified.
It was listening to villagers that convinced Mahmood that 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 came to his 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 now have American trainers keep their armor on and weapons at hand when visiting Afghan bases.)
The Afghan and U.S. soldiers initially thought the attack was coming from outside the outpost. They "didn't even thinking 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 had been killed and two 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," he said.
In August, the Taliban featured Mahmood in a propaganda video, calling him Ghazi of Ghaziabad. The video shows Mahmood being showered with praise by local elders and Taliban fighters.
The next month, the U.S.-led military coalition announced it had killed Mahmood in an airstrike. The coalition now says it was mistaken and 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 that he had only spoken to his mother, and that "she was happy."