By Wednesday night, U.S. intelligence agencies were near certain that an attack was imminent outside Kabul airport, triggering a State Department warning to American citizens to leave the area immediately.
Just over 12 hours later, a suicide bomber walked through the large crowds to a gate manned by U.S. troops and detonated explosives, killing at least 13 U.S. service members and 79 Afghans.
It was a tragic coda to America's 20-year war in Afghanistan, the largest loss of life for the U.S. military there in a decade, on the cusp of the full withdrawal of troops by Aug. 31 ordered by President Joe Biden.
Among the most pressing questions as the U.S. military launches its investigation: How did the bomber make it through Taliban checkpoints? Why were U.S. troops in such a concentrated space when they knew an attack was imminent?
"It was a failure somewhere," General Frank McKenzie, the head of U.S. Central Command, told reporters hours after the attack, which was claimed by Islamic State Khorasan (ISIS-K).
But at some point, McKenzie added, troops had no choice but to come in contact with people trying to board evacuation flights, screen them, pat them down for weapons, and ensure they did not make it into the airport if they posed a threat.
U.S. officials, speaking on condition of anonymity, said the conditions for the attack were set months in advance.
They told Reuters that weeks before the evacuation from Kabul airport began following the Taliban's takeover of the capital, the military had been seeking approval to get at-risk Afghans out of the country.
But the slow tempo of processing and inability to secure housing for the evacuees in third countries slowed down the pace of departures, according to the officials, at one point halting all flights from Kabul for six hours.
That meant troops were on the frontlines at the airport gates in the face of chaos outside.
"This didn't need to happen," a U.S. military official told Reuters.
"They didn't need to die."
DEBATE OVER BAGRAM
In the maelstrom of criticism aimed at Biden for the perilous evacuation of both U.S. citizens and Afghans who worked for the Americans, some have questioned his decision to hand back Bagram airbase in July, by far the United States' largest military facility in Afghanistan.
Some Republican lawmakers have argued that if the base had been kept open, the evacuation would have been more orderly.
U.S. officials rejected those arguments.
One U.S. defense official, speaking on condition of anonymity, said it would have taken an estimated 8,000 U.S. troops to secure Bagram, which likely would have been attacked by the Taliban as they swept to power. Americans wanting to leave the capital then would have faced a roughly 40-minute drive through Taliban checkpoints.
In the coming hours, the United States will turn its attention to withdrawing the approximately 5,000 troops at Kabul's airport - and the White House said on Friday the next few days will likely be the most dangerous of the operation.
ISIS terrorists have shot at aircraft already during the evacuation operation, but have had little success, according to the officials, who added that rocket attacks and suicide bombings will become an even larger threat as the number of U.S. troops dwindles.
The military is expected to continue to fly out evacuees even as they withdraw equipment and troops, though the number is expected to drop precipitously.
Officials said the withdrawal was particularly challenging because of a mixture of security threats along with a humanitarian crisis taking place outside the airport.
Unlike many previous military withdrawals, such as from Iraq in 2011, terrorist groups have been able to develop plans that focus on a single target, the airport, rather than on a number of U.S. bases.
Military planners are also desperate to avoid any repeat of the situation where thousands of desperate Afghans stormed the runway, hoping to get on a plane. Several died, some falling from airborne craft.
One of the U.S. officials said Biden's "Saigon" moment, the infamous U.S. evacuation from Vietnam in 1975, could still be to come as Afghans outside the airport realize the final stages of Washington's military withdrawal are underway.
SYMBOLIC RETALIATION?
Biden, his voice breaking with emotion, vowed on Thursday that the United States would hunt down those responsible for the airport attack, and said he had ordered the Pentagon to come up with plans to strike at the perpetrators.
On Friday, the U.S. military said it launched a drone strike that it believed had killed an Islamic State attack planner in eastern Afghanistan.
But officials have cautioned that beyond a symbolic act or limited operation, the United States could in fact do little to degrade ISIS-K.
"We've been trying to destroy the group in Afghanistan since 2014 and couldn't do it with thousands of troops on the ground," the defense official said.
Track Latest News Live on NDTV.com and get news updates from India and around the world