KABUL, Afghanistan — 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, 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, 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,” Mr. 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.