KABUL — On the day that Afghanistan’s capital fell to the Taliban, delivering the definitive verdict on a war that had lumbered on ambiguously for nearly 20 years, one of the city’s top security officials woke up preparing for battle.

The day before, government forces in the north’s largest city — Mazar-e Sharif, a notorious anti-Taliban stronghold — had surrendered with barely a fight. The same had happened overnight in Jalalabad, the traditional winter home of Afghanistan’s kings and the country’s main gateway to the east.

As dawn broke over the misty mountains that ring the city on Aug. 15, Kabul had suddenly become an island — the last bastion of a government that the United States had supported at a cost of trillions of dollars and thousands of lives. But it was an island that some were still prepared to defend.

“Everyone was ready to fight against the Taliban,” said the Afghan security official, who had spent the previous evening distributing new uniforms to his officers. “All the security forces were ready.”

Or so he thought. When he prepared to reinforce one of the main checkpoints protecting the city that morning, his commander waved him off. “He told me, ‘Leave that for now,’” the official recalled. “‘You can do it in a few days.’”

But Kabul didn’t have days.

Within hours, long-haired Taliban fighters had seized those checkpoints. The president had fled, not bothering to tell U.S. officials or even many of his own top lieutenants on his way out the palace door. And a country that has been whiplashed by multiple violent overthrows in its modern history was on course for a chaotic, destructive and humiliating end to the American era.

That outcome stunned top U.S. officials, several of whom had been on vacation when the weekend began, having expected the pro-Western government to hang on for weeks, if not months or even years longer. Afghans were no less astonished by the speed with which their government crumbled. Even the Taliban was surprised.

And in both countries, those who had dedicated themselves to keeping the extremist group out of power through decades of violent insurgency agreed on one thing: Had it not been for a few fateful choices that Sunday in mid-August, it all could have gone very differently.

A spur-of-the-moment decision by the president to escape the country, based on apparently incorrect information supplied by his advisers, was the most consequential. Later, the United States had one last chance to challenge Taliban supremacy in Kabul but opted to focus squarely on getting its people out from the airport.

This account of Kabul’s fall — the climactic moment of America’s longest war — is based on nearly two dozen interviews with U.S. and Afghan officials, a Taliban commander and residents of the city.

Before the fall

In both Washington and Kabul, the days and weeks leading up to Kabul’s fall were marked by complacency. The United States was withdrawing its forces. The Taliban was notching gains. But the prevailing view in both capitals was that there was still plenty of time before the insurgents might take over in a city of nearly 5 million that had long been the nerve center of America’s presence in the country.

President Ashraf Ghani exuded that belief, according to Afghan and U.S. officials who, like others for this story, spoke on the condition of anonymity to discuss sensitive matters.

A technocratic and mercurial former professor, Ghani told aides that Afghan forces could hold off the Taliban in the wake of the American departure, and that the government just needed six months to turn the situation around, according to a former Afghan official. Even as Taliban attacks intensified in rural Afghanistan and provincial capitals, his confidence remained unshaken.

“We’re fighting there so we don’t have to fight here,” he would insist from his perch in the Arg, Kabul’s 19th-century presidential palace.

But reports from the field suggested that in some cases, Afghan government forces were not fighting at all.

When the Taliban advanced on key border crossings with Iran and Tajikistan in late June and early July, government forces abandoned their posts. Hamdullah Mohib — the young, Western-educated official who served as Ghani’s national security adviser but who had scant experience in military or security affairs — told others the government forces would soon retake them.

But no significant attempts ever materialized, depriving the government of key sources of revenue. Mohib did not respond to requests for comment.

As the Taliban continued to accumulate gains, American officials began to see the president’s confidence as delusion.

Ghani’s lack of focus on the threat that the Taliban posed mystified U.S. officials, in particular, Marine Gen. Kenneth “Frank” McKenzie, head of U.S. Central Command, and Ambassador Ross Wilson.

In a July meeting with Ghani in Kabul, the two men told the Afghan president that his team needed a “realistic, implementable and widely supported plan to defend the country” and must drop the idea of defending all 34 provincial capitals, said an official familiar with the meeting.

“They had to focus on what they could actually defend,” said the official. “All provinces are important, but some were integral to the defense of Kabul.”

Ghani appeared to agree, but there would be no follow-through, the official said.

“Advice would be given, the right things would be said, and nothing would happen,” the official said. “They never did it. They never came up with that plan.”

Even as a cascade of provincial capitals fell — starting with Zaranj in the far southwest on Aug. 6, and continuing through two dozen others over the nine days that followed — the president appeared distracted.

“Ghani would want to talk about digitization of the economy,” said the official, referring to the president’s plan for a government salary payment system. “It had nothing to do with the dire threat.”

As late as the Saturday afternoon before Kabul fell, Ghani did not suggest any urgency around departure arrangements or the safety of senior staff.

Receiving one adviser in the palace gardens, and speaking in his characteristic soft tones, he made arrangements to shore up the country’s economy. He was supposed to address the nation later that night. But he never did.

The Americans, meanwhile, were suffering their own delusions.

In June, U.S. intelligence agencies had assessed that the Afghan government would hang on for at least another six months. By August, the dominant view was that the Taliban wasn’t likely to pose a serious threat to Kabul until late fall.

American officials may have been urging Ghani to show greater urgency. But their own actions suggested no immediate cause for alarm, with officials surrendering to the customary rhythms of Washington in August.

On the Friday afternoon before Kabul fell, the White House was starting to empty out, as many of the senior staff prepared to take their first vacations of Biden’s young presidency. Earlier in the day, Biden had arrived at Camp David, and Secretary of State Antony Blinken was already in the Hamptons.

But by Saturday, the fall of Mazar-e Sharif — site of furious battles between pro and anti-Taliban forces in the 1990s — convinced U.S. officials that they needed to scramble. How quickly was a subject of dispute between the Pentagon and State Department.

In a conference call with Biden and his top security aides that day, Defense Secretary Lloyd Austin called for the immediate relocation of all U.S. Embassy personnel to the Kabul airport, according to a U.S. official familiar with the call.

Wilson’s embassy colleagues had been racing to destroy classified documents and equipment in the compound since Friday. An internal memo, obtained by The Washington Post, implored staff to destroy sensitive materials using incinerators, disintegrators and “burn bins.” The directive also called for the destruction of “American flags, or items which could be misused in propaganda efforts.”

Wilson said U.S. personnel needed more time to complete their work. But Austin insisted time had run out, the official said.

Saturday evening Kabul time, Ghani and Blinken spoke by phone. Hoping to avert a showdown in the capital, Blinken sought Ghani’s support for a U.S.-brokered arrangement with the Taliban in which the militants would remain outside Kabul if the Afghan leader would step aside as an interim government took charge. The aim, said a senior U.S. official, was to buy time for negotiations aimed at forming an inclusive government that involved the Taliban, as well as others.

The president reluctantly agreed.

Precarious as it may have been, there appeared to be a path to a peaceful, political transition — a way for Afghanistan to avoid the sort of violent takeovers that have characterized so much of its recent past.

The fall

Taliban insurgents captured the key eastern Afghanistan city of Jalalabad without a fight on Aug. 15. (Reuters)

The news that Kabul awoke to that Sunday morning was ominous: The overnight fall of Jalalabad had left the capital isolated. Many shops remained shuttered, and people stayed home from work. But there was no sense that a takeover was imminent.

Nader Nadery, a former human rights activist, was flying out to Doha, Qatar, that morning to participate in negotiations with the Taliban. He knew the group’s fighters were nearing Kabul, but he believed that diplomacy could still spare the country from outright Taliban control and a return to the dark days of the 1990s.

When he reached the traffic circle just before the airport entrance, a police officer manning a checkpoint opened his vehicle door and recognized him. The officer radiated exhaustion.

“I will never forget his eyes,” Nadery said. “He had not slept in a long time. He seemed hopeless, and he said the situation was getting bad. But he also told me, ‘You are going to Doha, and we need you to bring peace. Please try to find a way.’”

At the presidential palace — set in the heart of Kabul, but behind a maze of blast walls that cut it off from much of the city — the morning unfolded with a bracing normality.

There were the usual meetings. Even as some senior officials grew increasingly panicked, asking about contingency plans to evacuate Ghani and others, the president’s personal secretary insisted he didn’t know of any, according to a former Afghan official. The government had until U.S. troops left on Aug. 31, the secretary said, as a result of the deal Ghani had struck the night before.

“A lot of reassurances were given. The American and British troops were still there. We were living our lives normally,” said Marjan Mateen, 28, who was a senior communications manager in the palace.

She was on her way into work late that morning, being driven through central Kabul in an armored car, when she began to realize something was very wrong.

First she saw university students hurrying home early with their backpacks, then shops closing and people running in panic. Taliban fighters had been seen at the city’s main entrances, and residents were fearing a battle to come.

“It was like a horror movie,” she said, “and you are a part of it.”

Within the palace, too, the illusion of calm was being punctured. Around midday, much of the staff had been dismissed for lunch. While they were gone, according to officials, a top adviser informed the president that militants had entered the palace and were going room to room looking for him.

That does not appear to have been true. The Taliban had announced that while its fighters were at the edges of Kabul, having entered through the city’s main checkpoints after security forces withdrew, it did not intend to take over violently. There was an agreement in place for a peaceful transition, and the group intended to honor it.

Yet that wasn’t the message that was being delivered to Ghani. The president was told by his closest aides that he needed to get out — fast.

“It will either be your palace guards or the Taliban,” the president was told, according to one adviser’s account, “but if you stay you’ll be killed.”

Mindful of the last time the Taliban had conquered Kabul — in 1996, when victorious fighters sought out the former Soviet-backed president, disemboweled him and hung his body from a traffic light — Ghani agreed to go.

The president wanted to return home to gather his belongings but was told by advisers that there was no time. Early that afternoon, wearing plastic sandals and a thin coat, the president — along with the first lady and a handful of top aides — lifted off from the palace grounds in military helicopters.

One palace official who fled with the president said he didn’t know where they were going until he saw the Hindu Kush — the colossal mountain range to the north of Kabul — rising outside the window.

The group eventually landed in Uzbekistan. From there, they boarded a small plane bound for the United Arab Emirates.

Ghani aides who had not been part of the hasty evacuation returned from lunch to find the president had vanished, his office empty.

The president, who did not respond to requests for comment, later justified leaving as a way to spare his country “a flood of bloodshed,” writing on Facebook that he faced a choice between being killed or “leaving the dear country that I dedicated my life to protecting the past 20 years.” But he did not inform most of the government’s senior ranks, including his two vice presidents, about his departure. Nor did Ghani contact the U.S. government, which was left to piece together the absent leader’s movements from rumor and media reports.

Not knowing Ghani had left, some senior Afghan officials continued to ask the palace for help. But at some point that afternoon, Ghani’s secretary stopped responding to messages.

Officials who had been left behind took the hint and made their own dash for the airport, hoping to get on commercial flights out that evening.

A handful, including the parliament speaker, were whisked away to Pakistan. The defense minister, Bismillah Khan Mohammadi, boarded a military flight to the UAE. Ghani’s second vice president, Sarwar Danish, and the head of the Afghan intelligence service, Ahmad Zia Saraj, also managed to leave.

Others were less fortunate. The hajj minister, a former Talib who had spoken out strongly against his former comrades, had his flight canceled, forcing him to return to a city where his friends-turned-enemies were fast becoming the de facto rulers.

Even after they had reached safety, the president and his party never circled back with senior officials who had been anxiously seeking their help. Some of those who had worked closely with Ghani over the years felt betrayed, believing he had left them to die.

Capital in chaos

The senior Kabul security official who had been waved away from reinforcing checkpoints that morning found out from a friend that the government he had been prepared to fight for was no more.

“The president’s gone,” the friend reported. “I think the government collapsed.”

He rushed to the airport, wanting to see for himself as an exodus began, with pilots and crews rushing to board planes and get airborne from a country suddenly confronted with a vacuum.

“Everyone was talking to each other like ‘What’s happened? What’s happened? What’s going on?’” he said.

U.S. officials were as surprised as anyone. The Americans had expected Ghani would stay for an orderly transition to an interim authority, as the agreement that negotiators in Doha had struck promised. News of Ghani’s departure, received secondhand, meant that hope had been crushed.

“He not only abandoned his country, but then unraveled the security situation in Kabul,” said a senior U.S. official. “People just simply melted away, from the airport to everywhere else.”

In the void, law and order began to break down, with reports of armed gangs moving through the streets.

In a hastily arranged in-person meeting, senior U.S. military leaders in Doha — including McKenzie, the commander of U.S. Central Command — spoke with Abdul Ghani Baradar, head of the Taliban’s political wing.

“We have a problem,” Baradar said, according to the U.S. official. “We have two options to deal with it: You [the United States military] take responsibility for securing Kabul or you have to allow us to do it.”

Throughout the day, Biden had remained resolute in his decision to withdraw all American troops from Afghanistan. The collapse of the Afghan government hadn’t changed his mind.

McKenzie, aware of those orders, told Baradar that the U.S. mission was only to evacuate American citizens, Afghan allies and others at risk. The United States, he told Baradar, needed the airport to do that.

On the spot, an understanding was reached, according to two other U.S. officials: The United States could have the airport until Aug. 31. But the Taliban would control the city.

Fighters were now on the move throughout Kabul, with the group’s spokesman issuing a revision of his earlier guidance: The Taliban hadn’t intended to take Kabul that day. But Ghani’s exit gave the group no choice.

“The government has left all of their ministries; you have to enter the city to prevent further disorder and protect public property and services from chaos,” read a message that pinged on Muhammad Nasir Haqqani’s phone.

Haqqani, a Taliban commander, had led his forces to the city’s gates that morning and been surprised by what he found.

“We didn’t see a single soldier or police,” he said. For several hours after, he had done as he was told, refraining from advancing further.

But after getting word that the government had collapsed, he and his men were in the city’s center within an hour. By late afternoon, they had reached the palace.

“We couldn’t control our emotions, we were so happy. Most of our fighters were crying,” he said. “We never thought we would take Kabul so quickly.”

For many others in Kabul, Haqqani’s source of joy was a cause for profound despair.

The sight of Taliban fighters taking up positions in the streets of Kabul accelerated an exodus that had already begun. The city’s perpetually jammed traffic was even more gridlocked than usual as people raced home from work or to the airport to try to catch a flight.

Mateen, the palace communications manager, was fielding calls from her colleagues as she sat in an armored car amid the mayhem.

“Don’t come,” they said, according to Mateen. “All the local staff is leaving. Just help us get our documents.”

She detoured to a relative’s house and realized she urgently needed to change her clothes: She had been wearing jeans and a shirt but knew that could now get her in trouble with the city’s new authorities.

“I had just seen my government fall right in front of my eyes,” she said. “I had this sudden feeling that everything was gone now. The flag of our country was not going to be there anymore. We were waking up to a new country ruled by the Taliban.”

Aria Raofi, an Afghan American who had been teaching photography to Afghan girls displaced by war, had a similar epiphany when she drove past a tank.

“Those were not Afghan soldiers in it. They were terrorists,” she said. She rushed home and hid in her apartment, only to discover that the Afghan security forces at her neighborhood checkpoint were gone, replaced by Taliban gunmen. She was soon making preparations to leave.

This footage from Al Jazeera shows Taliban fighters in Kabul's presidential palace on the day the group swept into the capital. (Al Jazeera)

At the palace, too, the Taliban had taken control. A lone guard had stayed behind to let the militants in and show them around. Looking slightly dazed, he told an Al Jazeera reporter how Ghani had called him and told him to work with former president Hamid Karzai to coordinate the handover.

The Al Jazeera cameras rolled as the fighters — fresh from 20 years in the shadows — gawked at the gilded trappings of power.

Nadery, who has not returned to Afghanistan since he flew to Qatar that Sunday, said the news that the Taliban had taken over felt like the worst kind of failure.

“I just sat there thinking, ‘I lost my country today,’” said Nadery, 40, who had been head of the country’s national civil service agency. “I saw everything I had fought for, for so many years, crumbling before my eyes.”

For the United States, the scope of defeat was total — and was vividly rendered as helicopters evacuated embassy personnel to the airport. Before the American flag was lowered one last time, diplomats engaged in a frenzy of destruction, burning documents and smashing sensitive equipment.

“It was extremely loud,” said a senior U.S. official. “There were controlled fires, the shredding of classified paper documents, and a constant pounding noise from the destruction of hard drives and weapons.”

By the time they were finished, what had once been the world’s largest diplomatic mission was “a strange-looking place,” the official said. “All the signage and photos were gone. Computers had the guts ripped out of them and the offices looked oddly bare.”

At the State Department, top brass, including Wendy Sherman, Blinken’s deputy, and Victoria Nuland, undersecretary of state for political affairs, were frantically calling foreign ministers to ask them to help with evacuation efforts and to coordinate a statement signed by 114 countries urging the Taliban to allow safe passage for evacuees. This, they realized, would be a historic evacuation effort.

As darkness enveloped the city, more and more people swarmed the airport — eventually overwhelming the modest terminal and spilling out onto the tarmac.

People desperate to flee Afghanistan flood the tarmac at Kabul airport Aug. 15 after the Taliban swept into the city earlier that day. (Associated Press)

But some had already given up hope that they would ever get out. That night, instead of going home, the senior Kabul security official went to a friend’s house. He has been hiding there ever since but is resigned to the fact that, sooner or later, the Taliban will probably find him.

His fate was sealed, he said, when Afghanistan’s president decided to save himself.

“From that moment, everything was smashed,” he said. “I’ve killed hundreds of Taliban. So for sure they will kill me.”

Ryan, Pager, Constable, Hudson and Witte reported from Washington. Anne Gearan in Washington contributed to this report.