KABUL: 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, US generals watched video screens with the same anticipation.
Relief washed over the war's winners and the losers when the final US plane took off.
For those in between and left behind -- possibly a majority of the allied Afghans who sought US clearance to escape -- fear spread about what comes next, given the Taliban's history of ruthlessness and repression of women.
And for thousands of US 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 US 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 US military machinery.
After several sleepless nights from the unrelenting thunder of US 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 centre 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."
t was a harrowing 24 hours, capped Monday by the final C-17 takeoff at 11:59 pm in Kabul.
Some who spoke to The AP about that period requested anonymity.
US officials who did so were not authorised to identify themselves.
Before leaving Kabul, a US 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 US 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 US 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 centre for unaccompanied child evacuees in Qatar.
More broadly, the US 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.
US embassies in Mexico, South Korea, India and elsewhere operated virtual call centres 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 US 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 US troops at the airport.
Some were caught off-guard by the US 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."
US efforts to get at-risk Afghans and others onto the airport grounds were complicated by the viral spread of an electronic code that the US 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 US 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 US 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."