Minutes before killing one of the most important generals in Afghanistan, the infiltrator made a final call to the Taliban.
Though only a teenager, the assassin managed to get hired as an elite guard, slipping into government service with a fake ID and no background check.
It put him so close to the center of power in Afghanistan that he was just paces away from Gen. Austin S. Miller, the commander of United States and NATO forces, when he suddenly raised his Kalashnikov and started firing in bursts.
The attack was a nightmare scenario for American and Afghan security planners: a Taliban operation months in the making that succeeded in breaching a high-level meeting, killing a powerful Afghan general and a provincial intelligence chief, wounding an Afghan governor and an American general — and barely missing General Miller and other officials standing nearby.
The infiltration and the chaotic American escape two weeks ago — detailed in interviews with more than a dozen people, including witnesses, family members and officials who have seen investigative reports — have deeply shaken the relationship between Afghan and American forces.
After 17 years of war and the killings of dozens of coalition service members by men in Afghan uniforms, the assault underscored how susceptible the Americans and Afghans remain to the kind of infiltration and insider attacks that, at their peak six years ago, almost derailed the NATO mission in Afghanistan.
The ambush last month also took the life of one of the nation’s most important bulwarks against the Taliban: Gen. Abdul Raziq, the police chief of Kandahar Province.
In his rise from lowly border guard to larger-than-life security chief in a little over a decade, General Raziq built nothing less than an empire in southern Afghanistan.
His status as the most powerful man in the Taliban heartland was built on brutal offensives against the insurgents, an effectiveness that kept a lid on ethnic and tribal differences, and his reputation with the American military as an indispensable ally who had kept Kandahar Province secure for years.
On the afternoon of Oct. 18, all of that crumbled in a matter of seconds.
The scramble to get the Americans out of the governor’s compound after General Raziq was killed led to a brief firefight between American and Afghan security forces, with the Americans crashing through a gate and shooting at least one Afghan officer dead as they left, American officials said.
Now, in the days that have followed, the Americans are being accused of General Raziq’s death, rattling the relationship between the allies.
Across Afghanistan, a rumor has spread that the United States must have been behind the killing of General Raziq. That rumor began immediately at the scene of the attack, and spread to social media pages, the streets and even among the country’s top leaders.
In a private meeting, former President Hamid Karzai told the American ambassador, John Bass, that most of the country believed that the Americans assassinated Mr. Raziq at Pakistan’s behest, according to American officials. Just two days after the attack, an Afghan soldier was reported to have opened fire on NATO forces after an argument over the killing of General Raziq.
Aside from airstrikes, American troops largely retreated into a defensive posture in the weeks after the attack. Joint operations were cut back, and interactions between officials were mostly relegated to phone calls and heavily guarded meetings as the American-led mission put in place new security protocols, American officials said.
The attack took place at the Kandahar governor’s compound, where American and Afghan officials were meeting to discuss security for the nation’s elections last month.
General Raziq had reduced his appearances at the compound in recent months and hunkered deeper into his own palace, partially because he barely missed an attack last year by a Taliban bomber who killed and injured a room full of V.I.P.’s.
He had also been busy with presidential politics and was likely using his contact network to help in efforts to establish peace talks with the Taliban. He had flown to Kabul and Dubai and Europe for discussions. “My hat does security, I do politics,” he had joked.
Ghorzang Afghan, a longtime assistant to General Raziq, said his boss, who was attending his first large meeting after several days of illness, had seemed worried the day of the attack. He had reports of threats, but he could not pin them down specifically.
“He asked us to pay special attention and get our guards up on all the towers,” Mr. Afghan said.
During the meeting with provincial and American officials, a young Afghan guard sat at the entrance of the conference room. American officials described him as more reserved than the rest of the guards. He carried two Kalashnikovs — one slung across his chest and one behind his back.
The other guards knew him as Gulbuddin. But his real name, American officials said, was Raz Mohammed, and about six months before the attack he had trained with the Taliban in Pakistan. After the attack, the insurgents put out a video of his training, including target shooting.
Sometime in August, he had arrived in Kandahar and enlisted among the elite guards of the provincial governor. One of his cousins, Basir Ahmad, who had been a guard of the governor for nearly a year, vouched for him, helping him to skip a background check.
“He was quiet — he would rarely say a word,” said Mohammed Nasim, one of the governor’s guards who shared the barracks with him. “But Basir Ahmad would always be on his phone.” (Mr. Ahmad fled the compound 30 minutes before the shooting, officials said.)
Mr. Mohammed made a final call to Pakistan, either five or 15 minutes before the attack, according to two different accounts by officials, and he spoke for about two and a half minutes to a Taliban commander responsible for leading suicide attacks.
When the meeting was over, the dignitaries made their way behind the compound to a helicopter landing pad, where General Miller’s pair of Black Hawks would arrive to take him to Kabul.
Pomegranates had come into season in Kandahar, and the governor had cases of them as gifts for his guests. Many of the guards, including the gunman, were carrying cases of the fruit as the group made its way to the helipad.
Mr. Mohammed moved to the front of the group, put his case of pomegranates down and suddenly raised his weapon. He trained the assault rifle on General Raziq, who was about five feet from him, and fired a first burst of four shots. Then, he sprayed a second burst toward those next to General Raziq, including General Miller, before being shot by one of the Americans. As he went down, more bullets from every direction rained on him.
“The whole thing probably didn’t last longer than 10 seconds,’’ said Massoud Akhundzada, the custodian of a religious shrine in Kandahar, who was steps away.
One of General Raziq’s armored vehicles sped to the scene, splashed red with blood and crushed pomegranates, to pick him up and rush him to the hospital.
Their weapons drawn, General Miller and the other Americans tried to find cover. They called for medevac helicopters as they tried to secure the area. Tracer rounds landed from several directions. When things got quieter, they tended to the wounded, who included the Kandahar governor and Brig. Gen. Jeffrey Smiley, the commander of American forces in southern Afghanistan.
An Afghan guard was heard shouting that the Americans had fired at General Raziq, according to American officials. They say the guard may have been a second infiltrator trying to stoke anger and deflect blame.
After General Miller, other American commanders and some of the wounded departed on the helicopters, members of the American ground convoy tried to make their way out of the governor’s palace to their base at Kandahar Airfield. They clashed with Afghan forces at the palace gates and exchanged fire.
One of the Afghan guards was shot dead by an American gunner while the vehicles rammed through the gate, Afghan and American officials said. The convoy was attacked one more time at a traffic circle, according to American officials.
In Kandahar, the security of one of most critical provinces in Afghanistan was immediately cast into question with the death of General Raziq, who held together by force of personality a network that outstripped the capabilities of the central Afghan government anywhere outside Kabul, the capital.
When General Raziq was made police chief of Kandahar in 2011, while in his early 30s, the Taliban were at the city gates. In fact, they would frequently grab government employees from the heart of the city to a kangaroo court on the outskirts. Two of General Raziq’s predecessors as police chief were killed on the job.
General Raziq was ruthless in his pushback, personally leading operations that dealt heavy casualties to the Taliban. Human rights groups accused him of torture and extrajudicial killings, including of tribal rivals. But as he established his grip in recent years and turned to national politics, officials described him as more disciplined and cautious.
General Raziq’s death sent the Taliban into a frenzy of celebration, captured on videos circulating on social media accounts. At the central prison in Kabul, dozens of Taliban inmates danced to an improvised group chant: “O, they killed Raziq! In Kandahar, they killed Raziq!” (Song and dance were forbidden when the Taliban controlled Afghanistan.)
“This Raziq martyred 2,800 people, without a court and justice, and buried them in the sands of Kandahar as their mothers still wait,” a Taliban official, Mawlawi Abdul Ghafoor, told a packed gathering of Taliban in Quetta, Pakistan, where the group’s leaders are based. “The Talib who tore a hole in Raziq’s chest — may God unite us with him in heaven. And may God unite Raziq with his Scott Miller.
“One of our leaders was saying he wished Scott Miller was also gone. I said, ‘Why are we so greedy?’ I wouldn’t have been as happy if 500 Americans were killed as I am that Raziq is killed.”
General Raziq became an overnight national martyr of a battered nation. His picture is on billboards in roundabouts and on windows of bakeries. His grave, just outside the governor’s compound where he was killed, has already become a shrine.