(AP) -- Bone-tired like everyone else in Kabul, Taliban fighters spent the last moments of the 20-year Afghanistan war watching the night skies for the flares that would signal the United States was gone. From afar, U.S. generals watched video screens with the same anticipation.
Relief washed over the war's winners and the losers when the final U.S. plane took off.
For those in between and left behind -- possibly a majority of the allied Afghans who sought U.S. clearance to escape -- fear spread about what comes next, given the Taliban's history of ruthlessness and repression of women. And for thousands of U.S. officials and volunteers working around the world to place Afghan refugees, there is still no rest.
As witnessed by The Associated Press in Kabul and as told by people The AP interviewed from all sides, the war ended with episodes of brutality, enduring trauma, a massive if fraught humanitarian effort and moments of grace.
Enemies for two decades were thrust into a bizarre collaboration, joined in a common goal -- the Taliban and the United States were united in wanting the United States out. They wanted, too, to avoid another deadly terrorist attack. Both sides had a stake in making the last 24 hours work.
In that stretch, the Americans worried that extremists would take aim at the hulking, helicopter-swallowing transport planes as they lifted off with the last U.S. troops and officials. Instead, in the green tint of night-vision goggles, the Americans looked down to goodbye waves from Taliban fighters on the tarmac.
The Taliban had worried that the Americans would rig the airport with mines. Instead the Americans left them with two useful fire trucks and functional front-end loaders along with a bleak panorama of self-sabotaged U.S. military machinery.
After several sleepless nights from the unrelenting thunder of U.S. evacuation flights overhead, Hemad Sherzad joined his fellow Taliban fighters in celebration from his post at the airport.
"We cried for almost an hour out of happiness," Sherzad told The AP. "We yelled a lot -- even our throat was in pain."
In the Pentagon operations center just outside Washington at the same time, you could hear a pin drop as the last C-17 took off. You could also hear sighs of relief from the top military officials in the room, even through COVID masks. President Joe Biden, determined to end the war and facing widespread criticism for his handling of the withdrawal, got the word from his national security adviser during a meeting with aides.
"I refused to send another generation of America's sons and daughters to fight a war that should have ended long ago," he said.
Gen. Mark Milley, chairman of the Joint Chiefs of Staff, was among those watching at the Pentagon. "All of us are conflicted with feelings of pain and anger, sorrow and sadness," he said later, "combined with pride and resilience."
It was a harrowing 24 hours, capped Monday by the final C-17 takeoff at 11:59 p.m. in Kabul. Some who spoke to The AP about that period requested anonymity. U.S. officials who did so were not authorized to identify themselves.
Before leaving Kabul, a U.S. consular officer with 25 years at the State Department was busy trying to process special visas for qualifying Afghans who made it through the Taliban, Afghan military and U.S. checkpoints into the airport. What she saw was wrenching.
"It was horrendous what the people had to go through to get in," she said. "Some people had spent three to five days waiting. On the inside we could hear the live ammunition being fired to keep the crowds back and the ones who made it in would tell us about Taliban soldiers with whips, sticks with nails in them, flash-bang grenades and tear gas pushing people back."
Even more upsetting, she said, were the children who got inside the airport separated from family, some plucked by chance out of teeming crowds by U.S. troops or others. As many as 30 children a day, many confused and all of them frightened, were showing up alone for evacuation flights during the 12 days she was on the ground.
A small unit at the airport for unaccompanied children set up by Norway was quickly overwhelmed, prompting UNICEF to take over. UNICEF is now running a center for unaccompanied child evacuees in Qatar.
More broadly, the U.S. sent thousands of employees to more than a half-dozen spots around Europe and the Middle East for screening and processing Afghan refugees before they moved on to the United States, or were rejected. U.S. embassies in Mexico, South Korea, India and elsewhere operated virtual call centers to handle the deluge of emails and calls on the evacuations.
Over the previous days in Kabul, many Afghans were turned back by the Taliban; others were allowed past them only to be stopped at a U.S. checkpoint. It was madness trying to sort out who satisfied both sides and could make it through the gauntlet.
Some Taliban soldiers appeared to be out for rough justice; others were disciplined, even collegial, over the last hours they spent face to face with U.S. troops at the airport. Some were caught off-guard by the U.S. decision to leave a day earlier than called for in the agreement between the combatants.
Sherzad said he and and fellow Taliban soldiers gave cigarettes to the Americans at the airport and snuff to Afghans still in the uniform of their disintegrating army.
By then, he said, "everyone was calm. Just normal chitchat." Yet, "We were just counting minutes and moments for the time to rise our flag after full independence."
U.S. efforts to get at-risk Afghans and others onto the airport grounds were complicated by the viral spread of an electronic code that the U.S. sought to provide to those given priority for evacuation, said a senior State Department official who was on the ground in Kabul until Monday.
The official said the code, intended for local Afghan staff at the U.S. Embassy, had been shared so widely and quickly that almost all people seeking entry had a copy on their phone within an hour of it being distributed.
At the same time, the official said, some U.S. citizens showed up with large groups of Afghans, many not eligible for priority evacuation. And there were Afghan "entrepreneurs" who would falsely claim to be at an airport gate with groups of prominent at-risk Afghan officials.
"It involved some really painful trade-offs for everyone involved," the official said of the selections for evacuation. "Everyone who lived it is haunted by the choices we had to make."
The official said it appeared to him, at least anecdotally, that a majority of the Afghans who applied for special visas because of their past or present ties with the U.S. did not make it out.
Among the hurdles was the design of the airport itself. It had been constructed with restrictive access to prevent terrorist attacks and did not lend itself to allowing any large groups of people inside, let alone thousands frantically seeking entry. All of this unfolded under constant fear of another attack from an Islamic State offshoot that killed 169 Afghans and 13 U.S. service members in the Aug. 26 suicide bombing at the airport.
There were times, said another U.S. official familiar with the process, when Afghans made it on to evacuation planes, only to be pulled off before the flight when they were found to be on no-fly lists.
This official said that as far as is known, all but one U.S. Embassy employee made it out. That person had the required special visa but couldn't bear to leave her parents and other relatives behind. Despite pleading from Afghan and American colleagues to get on the evacuation bus to the airport, she opted to stay, the official said.
But a 24-year-old former U.S. contractor, Salim Yawer, who obtained visas and a gate pass with the help of his brother, a U.S. citizen, never got out with his wife and children aged 4 and 1 1/2. They tried four times to get to the airport before the Americans left.
"Each time we tried getting to the gate, I was afraid my small children would come under feet of other people," he said. He, too, did not expect the Americans to leave Monday, and he went back to the airport the next day.
"We didn't know that night that the Americans would leave us behind," Yawer said. "Monday, still, there were U.S. forces and planes and hopes among people. But Tuesday was a day of disappointment. ... Taliban were all over the area and there was no plane in the sky of Kabul anymore."
Yawer owned a Kabul construction company and traveled to various provinces doing work for the U.S. Army Corps of Engineers, he said from his village back in northern Kapisa province, where he fled.
On the evening of Sunday, Aug. 29, in Kabul, surveillance showed people loading explosives into the trunk of a vehicle, U.S. officials said. The U.S. had been watching the car for hours, with reports of an imminent threat of another Islamic State militant attack. An American RQ-9 Reaper drone launched a Hellfire missile into the vehicle, in a compound between two buildings. U.S. officials said surveillance showed the initial missile explosion, followed by a large fireball, which they believed to be caused by the explosives in the vehicle. Neighbors disputed the U.S. claims of a vehicle packed with explosives.
On the ground, Najibullah Ismailzada said his brother-in-law Zemarai Ahmadi had just arrived home from his job working with a Korean charity. As he drove into the garage, his children came out to greet him, and that's when the missile struck.
"We lost 10 members of our family," Ismailzada said. Six ranged in age from 2 to 8. He said another relative, Naser Nejrabi, who was an ex-soldier in the Afghan army and interpreter for the U.S. military, also was killed, along with two teenagers.
Several hours after the drone strike, Biden was at Dover Air Force Base in Delaware to witness the dignified transfer of the remains of the 13 U.S. troops killed in the previous week's suicide bombing and to meet the bereaved families. The card he keeps with him, listing the number of American service members who have died in Iraq and Afghanistan, had been updated with "plus 13," according to a person familiar with the president's exchange with the families.
In the final scramble at the Kabul airport that evening, evacuees were directed to specific gates as U.S. commanders communicated directly with the Taliban to get people out.
-- About 8 a.m. Monday, explosions could be heard as five rockets were launched toward the airport. Three fell outside the airport, one landed inside but did no damage and one was intercepted by the U.S. anti-rocket system. No one was hurt.
Again, Islamic State militants, common foe of both the Taliban and the Americans, were suspected as the source.
-- Through the morning, the last 1,500 or so Afghans to get out of the country before the U.S. withdrawal left on civilian transport. By 1:30 p.m., 1,200 U.S. troops remained on the ground and flights began to move them steadily out.
U.S. airpower -- bombers, fighter jets, armed drones and the special operations helicopters known as Little Birds -- provided air cover.
-- Into the evening, U.S. troops finished several days' work destroying or removing military equipment. They disabled 27 Humvees and 73 aircraft, often draining transmission fluids and engine oil and running the engines until they seized. They used thermite grenades to destroy the system that had intercepted a rocket that morning. Equipment useful for civilian airport purposes, like the fire trucks, were left behind for the new authorities.
-- At the end, fewer than 1,000 troops remained. Five C-17 planes came in darkness to take them out, with crews specially trained to fly into and out of airfields at night without air traffic control.
From Scott Air Force Base in Illinois, Gen. Jacqueline Van Ovost, commander of Air Mobility Command, watched on video screens as the aircraft filled and lined up for takeoff. An iconic image showed Maj. Gen. Christopher Donahue, commander of the 82nd Airborne Division, carrying his M-4 rifle as walked into a C-17 and into history as the last of the U.S. soldiers in Afghanistan.
Crisp orders and messages captured the last moments.
"Chock 5 100% accounted for," said one message, meaning all five aircraft were fully loaded and all people accounted for. "Clamshell," came an order, meaning retract the C-17 ramps one by one. Then, "flush the force," meaning get out.
-- One minute to midnight, the last of the five took off.
Soon came the message "MAF Safe," meaning the Mobility Air Forces were gone from Kabul air space and in safe skies.
The American generals relaxed. From the ground in Kabul, Taliban fighter Mohammad Rassoul, known among other fighters as "Afghan Eagle," had been watching, too.
"Our eyes were on the sky desperately waiting," he said. The roar of planes that had kept him up for two nights had stopped. The Taliban flares at the airport streaked the sky.
"After 20 years of struggle we achieved our target," Rassoul said. He dared hope for a better life for his wife, two daughters and son.
"I want my children to grow up under peace," he said. "Away from drone strikes."