KABUL — Taliban fighters took control of Kabul on Sunday, delivering the militant Islamist group the prize it has long sought: authority over all of Afghanistan as the Western-backed government collapsed, President Ashraf Ghani fled, and the long-dominant American presence appeared to be coming to an abrupt and chaotic end after nearly 20 years.

The takeover of the sprawling capital city had been years in the making, but was ultimately accomplished in a single day. Insurgent fighters, fresh off their conquests in each of Afghanistan’s provincial hubs over the previous week, faced little to no resistance as they entered the city through its major traffic arteries Sunday morning.

By evening, the Taliban was giving television interviews in the lavish presidential palace, just hours after Ghani had departed Afghanistan. A desperate exodus was underway at the airport, with thousands of people clamoring to board flights. And the Pentagon was speeding in additional troops to assist with the withdrawal of U.S. personnel after the American flag was lowered from a now-abandoned embassy.

The footage of rifle-toting Taliban fighters occupying the presidential palace and rolling up the Afghan national flag stood as a defining image of a failed U.S. effort to transform Afghan society at the cost of a trillion dollars and thousands of lives lost.

“Decades from now, these images will be invoked as a vivid example of the limits of U.S. power, and of its inability to fight modern wars effectively or to end them on favorable terms,” said Michael Kugelman, an Afghanistan scholar at the Wilson Center.

Asked about comparisons to the United States’ departure from Vietnam in 1975, Secretary of State Antony Blinken said on ABC News’s “This Week” that “this is manifestly not Saigon.” But the frenzied rush to the exits exuded anything but the calm and orderly withdrawal the administration had promised.

As the Taliban encircled and then entered Kabul on Sunday, U.S. personnel at the embassy in Afghanistan relocated to the airport along with acting U.S. ambassador Ross Wilson, who left the sprawling U.S. compound with the American flag. As of late Sunday, “all embassy personnel” had been moved to the airport, the State Department said in a statement.

In a briefing to lawmakers, Defense Secretary Lloyd Austin said the airport had been reopened to commercial flights. But many Americans and Afghans seeking to flee said they were turned away and told flights had been canceled. Officials said they hoped the Taliban would allow them to continue flights over the next several days.

Emerging as the undisputed winner of America’s longest war, Taliban co-founder Abdul Ghani Baradar struck a conciliatory tone in a video statement recorded in Doha.

“We have reached a victory that wasn’t expected … we should show humility in front of Allah,” said Baradar, head of the Taliban’s political bureau. “Now it’s about how we serve and secure our people and ensure their future to the best of our ability.”

But with the Taliban’s takeover complete, there was deep apprehension that the group’s brutal tactics — for which it was known during its five years in power before being ousted by the U.S.-led invasion after 9/11 — would soon return.

U.N. Secretary General António Guterres issued a statement saying the events raised “deep concern,” especially when it comes to the future of women and girls. The United Nations Security Council will hold an emergency meeting on Afghanistan Monday morning.

Ghani did not appear publicly on Sunday. But on his Facebook page, he posted a message explaining that the Taliban had given him no choice but to depart the country. “In order to avoid a flood of blood, I thought it was best to get out,” he said.

On Capitol Hill, Republicans blasted what they called a “chaotic retreat” following the Biden administration’s decision to withdraw remaining U.S. troops, though most refrained from calling for a return to war.

“Over the last 48 hours, we have doubled the number of military personnel in Afghanistan that we just withdrew — but only to facilitate a disgraceful exit that will cap off a total failure,” said Sen. James M. Inhofe (Okla.), the top Republican on the Senate Armed Services Committee.

Blinken took to the Sunday TV shows to defend the Biden administration’s decision to withdraw, arguing that the Taliban’s current offensive would have happened even if U.S. forces remained in Afghanistan.

“If the president had decided to stay, all gloves would’ve been off, we would’ve been back at war with the Taliban, attacking our forces, the offensive you’ve seen throughout the country almost certainly would’ve proceeded,” Blinken told NBC News.

Blinken did not directly answer the question of how the United States failed to anticipate the speed of the Taliban’s takeover. As of last week, the U.S. military had estimated a collapse could take 90 days. In June, American officials had forecast a collapse in six to 12 months.

Instead, it took 10 days, with provincial capitals falling one after the next.

Footage from Al Jazeera from inside the presidential palace late Sunday showed Taliban leaders with long beards and turbans seated around a wooden table, as militants wielding assault rifles stood behind them. Some lounged on gilded chairs.

The Taliban “wants a participatory government with various components of the Afghan people,” Qari Salahuddin, the Taliban’s central security official, told Al Jazeera Arabic.

He said arrangements were underway for the return of the movement’s leaders to Kabul.

The Taliban sent squads of 15 armed men each to all government headquarters, embassies and diplomatic missions to protect them, and had set up checkpoints along the city’s entrances and main streets, a leader told Al Jazeera.

In messages apparently distributed to Kabul residents via the messaging group WhatsApp, the group proclaimed that “we are in charge of security for Kabul.” The messages listed telephone numbers in various neighborhoods that citizens should call if they saw problems such as looting or “irresponsible” behavior on the part of armed individuals.

“The Islamic Emirate assures you that no one should be in panic of feeling fear,” one message said. “Taliban is taking over the city without fighting and no one will be at risk.”

Meanwhile, Afghan leaders who have been the Taliban’s nemesis for the past two decades issued pleas for the group to refrain from retributory violence.

Former Afghan president Hamid Karzai appeared in a video posted online, surrounded by his three daughters as a helicopter whirred overhead. He said he hoped that “the problems of our country and our capital … will be solved” and that the Taliban “will guard the safety of the people’s lives and property.”

Other figures closely associated with the American-backed government, including Gul Agha Sherzai, the former governor of Nangahar province, recorded videos congratulating the Taliban on its victory.

But Ghani’s departure, apparently to neighboring Tajikistan with his family and much of his government, dissolved plans in place as recently as Saturday to send a team to Doha to negotiate a transition with the Taliban.

Instead, High Council for National Reconciliation Chair Abdullah Abdullah announced the formation of a new “coordination council” with Karzai and former warlord-turned-politician Gulbuddin Hekmatyar to deal directly with the Taliban in Kabul. Its purpose, Karzai said on Twitter, is to “prevent chaos … and to better manage the affairs related to peace and the peaceful transfer” of power.

The Taliban has not responded publicly to the group, but U.S. officials assume that the militants are equally interested in preventing violence as they consolidate their control. There is no sense among those officials that a power-sharing government is being discussed. Rather, the Taliban was expected to set the terms and the council would facilitate its nonviolent takeover.

U.S. officials, focused on the evacuation, are not involved in the Afghan-to-Afghan talks.

Over years of pushing for negotiations to end the war, the United States has long insisted that any solution must be “Afghan-led” and not imposed by Americans. That now appears to be happening, although not in the way, or with an outcome, envisioned by successive U.S. administrations.

The Taliban’s lightning-quick advance to the Afghan capital came as helicopters landed at the U.S. Embassy early Sunday and armored diplomatic vehicles were seen leaving the area around the compound. Diplomats scrambled to destroy sensitive documents, sending smoke from the embassy’s roof, said two State Department officials familiar with the situation.

State Department officials had preferred to evacuate the U.S. Embassy over multiple weeks, two U.S. officials told The Washington Post on Saturday. Defense officials did not think that was realistic, but waited to begin deploying additional troops to Kabul until the Biden administration made the call Thursday to begin withdrawing. The bulk of those troops were expected to arrive by the end of the weekend, Pentagon spokesman John Kirby said Friday.

The Pentagon is expected to deploy another 1,000 troops to Afghanistan from a brigade combat team with the 82nd Airborne Division resulting in a total of 6,000 U.S. troops on the ground at Kabul International Airport. In a joint statement, the Pentagon and State Department said the United States would be transferring out thousands of Americans and Afghans “over the coming days" and was taking over air traffic control at the airport.

State Department spokesperson Ned Price said Sunday night that the perimeter of the airport had been secured by U.S. forces. Some other forces, including Turks, remained, the official said.

Earlier in the day, the exit moved forward — though in a highly precarious atmosphere.

Nongovernmental organization officials said they had received queries from military officials about conditions at the airport, suggesting the U.S. government was struggling to get real-time information.

Accounts circulated on social media of chaotic scenes at the airport, as foreigners and Afghans desperately sought to flee the country. A video on Snapchat showed crowds massing under a plane on the tarmac Sunday night, as people were pulled into what appeared to be a military cargo plane.

The fall of Kabul came just a day after the Taliban seized Mazar-e Sharif — a northern city long seen as an anti-Taliban stronghold.

And it came hours after the capture of Jalalabad, close to Afghanistan’s border with Pakistan, which came with minimal resistance after militants and local elders negotiated the fall of the city’s government.

Bagram and Sorobi districts in Kabul province also surrendered without shots being fired, according to an official, who added that the militants had made “political deals” with local leaders.

Afghan forces on Sunday handed over Bagram air base — once the U.S. military’s most important airfield in the country — to the Taliban, a district chief told the AP. The air base holds a prison housing 5,000 inmates.

The Taliban also took control of Afghanistan’s largest prison, known as Pul-e-Charkhi, CNN reported, citing two unnamed Taliban sources. Up to 5,000 inmates may have been housed at the infamous prison east of Kabul, according to CNN.

Footage from an Afghan news agency on Sunday appeared to show Taliban militants letting inmates out of the prison, the BBC reported.

On Aug. 14, President Biden approved additional military forces to help safely draw down the American embassy and remove personnel from Afghanistan. (Reuters)

Several other countries that had retained a diplomatic presence in Kabul even as Taliban gains accelerated began withdrawing staff. Germany, Denmark and Norway all said they would suspend operations. The British ambassador was scheduled to be airlifted from Afghanistan by Monday evening, the Sunday Telegraph newspaper reported. Iranian officials said its embassy in Kabul would be evacuated by Monday. Other governments, including Russia and Turkey, said their missions would continue to operate.

Blinken was pressed by multiple television hosts Sunday about why the U.S. withdrawal appeared haphazard — particularly given the decision to withdraw forces, then send them back in. Blinken denied being caught flat-footed.

“The president was prepared for every contingency as this moved forward,” he said. “We had those forces on hand and they were able to deploy very quickly again to make sure that we could move out safely.”

Administration officials briefed lawmakers in two calls Sunday morning.

In the administration’s call with senators, Sen. Lindsey O. Graham (R-S.C.) asked whether the U.S. government’s assessment of the terrorist threat to the United States had changed as a result of the Taliban’s victory, said one Republican senator, who spoke on the condition of anonymity because of the sensitivity of the issue.

Austin had testified in June that it could take two years for an extremist group to regenerate, and assessed the likelihood of that occurring as medium.

Austin responded that the assessments have changed because of the lack of a cohesive security force on the ground. He suggested he could provide a more complete answer in a classified setting, the senator said.

Austin also said that the military will run as many aircraft as it can to rescue people, with U.S. Embassy workers at the front of the list. Afghans with still-processing special immigrant visas would be next, followed by others who seek to come to the United States through other categories.

“It sounds like they’re going to try to get as many out as possible, but with the situation deteriorating so rapidly, our question that is largely unanswered is how long can this sustain, and how many people will we actually get out?” the senator said. “We really don’t know that.”

Parker reported from Billings, Mont., and Lamothe, DeYoung and Hudson reported from Washington. Pietsch reported from Seoul. Mahnaz Rezaie, Missy Ryan and Tara Bahrampour in Washington contributed to this report.