IE 11 is not supported. For an optimal experience visit our site on another browser.

The cost of the war was staggering. But Afghanistan's future is more unclear than ever.

The attack underscored concerns that terrorist groups will be among the winners as America ends its longest war.

The suicide bombing at Kabul airport Thursday served as a deadly reminder that America is leaving behind a country that is unstable and insecure — the opposite of what it intended to create.

The United States invaded Afghanistan two decades ago in the wake of 9/11 attacks, toppling the Taliban regime after it sheltered Al Qaeda leader Osama bin Laden and launching the war on terror. But just weeks before the 20th anniversary of the deadliest terror attack on American soil, Afghanistan is once again in the hands of the Taliban, while extremists are disrupting an already chaotic attempt to evacuate U.S. citizens and Afghans who are at risk.

The blast, which killed more than 100 civilians and 13 U.S. service members, underscored concerns that terrorist groups will be among the winners as America ends its longest war.

A U.S. Marine takes up a fighting position after off loading from a helicopter in Main Poshteh, Afghanistan. Joe Raedle / Getty Images file

On Oct. 7, 2001, then-President George W. Bush told the nation that its military had begun strikes against Al Qaeda training camps and military installations of the Taliban government in Afghanistan.

“These carefully targeted actions are designed to disrupt the use of Afghanistan as a terrorist base of operations, and to attack the military capability of the Taliban regime,” he said.

Now the security vacuum left behind as the U.S. exits could not only benefit the Afghan offshoot of the Islamic State terror group, U.S. officials have warned, but also Al Qaeda, which — according to the United Nations — maintains a presence in Afghanistan.

The carnage outside Kabul airport — which neither the United States nor the Taliban were able to prevent — prompted anger and concern on Capitol Hill.

Download the NBC News app for breaking news and politics

“We simply cannot strand Americans behind enemy lines in the new capital city of global jihad,” Sen. Ben Sasse, R-Neb., said in a statement following Thursday’s attack. New York Rep. Carolyn B. Maloney and Massachusetts Rep. Stephen F. Lynch, both Democrats, said in a joint statement that the bombing was a “tragic reminder” of how dangerous the situation remains in Afghanistan.

President Joe Biden had warned about the growing risk of a terrorist incident in recent days and argued for sticking to his deadline to withdraw troops from Afghanistan by Aug. 31. The Taliban have described the deadline as a “red line” that if crossed would provoke consequences.

The militant group took the Afghan capital Aug. 15 without firing a shot after a military blitz that stunned even its own fighters.

But nearly two weeks later, the Taliban have yet to form a government and reports of repression — as well as the violence and chaos at Kabul airport — have contributed to mounting evidence that taking a country by force is easier than successfully governing it.

Mohboba, 7-years-old, stands against a bullet-ridden wall as she waits to be seen at a health clinic in Kabul in 2002. Paula Bronstein / Getty Images file

Last week, the group’s fighters suppressed scattered protests amid warnings that Afghanistan’s already weakened economy could crumble further without the massive international aid that sustained the ousted U.S.-backed government. Meanwhile, a pocket of resistance has emerged in the Panjshir Valley, north of Kabul, where a small armed force has vowed to confront the Taliban.

Two Taliban leaders acknowledged to NBC News that they thought the group had bungled parts of its takeover of Afghanistan.

The biggest blunder, they said, was releasing prisoners from jails as they swept across the arid mountainous country, with those freed thought to include hardcore ISIS commanders, trainers and bomb makers.

"They were very trained people and they are now organizing themselves,” the Taliban leaders said.

A U.S. Marine tries to communicate with some Afghan girls during a village medical outreach in Helmand province, Afghanistan in 2010.Paula Bronstein / Getty Images file

The Taliban are no friends of ISIS and the two groups push separate agendas. The Taliban are primarily Pashtun nationalists who want to govern Afghanistan, while ISIS wants to set up an Islamic state that includes but is not limited to Afghanistan.

Although a U.S.-led coalition successfully eliminated territorial gains by ISIS in Iraq and Syria, there is concern among countries that foreign terror fighters from that region could move to Afghanistan if the environment there becomes more hospitable to ISIS or groups aligned with Al Qaeda, according to a U.N. report from late last month.

By contrast, the Taliban and Al Qaeda remain closely aligned and show no indication of breaking ties, according to a separate June U.N. report.

As part of the Doha agreement, signed by the Trump administration and the Taliban in February 2020, the militants agreed to not allow any of their members, other individuals or groups, including Al Qaeda, to use the soil of Afghanistan to threaten the security of the United States and its allies.

President Joe Biden walks through Arlington National cemetery to honor fallen veterans of the Afghan conflict in Arlington, Va., in April. Brendan Smialowski / AFP via Getty Images file

The June U.N. report says Al Qaeda’s near-term strategy is assessed as maintaining its traditional safe haven in Afghanistan, but notes assessments that have suggested a longer-term strategy of “strategic patience” before it would seek to plan attacks against international targets again.

“This scenario is untested against stated Taliban commitments to prohibit such activities,” the report says.

Soon it will be, however, as the U.S. is set to complete its withdrawal by Tuesday.

The day the U.S. completes its withdrawal will be a solemn one. Tens of thousands of people have died in the conflict and some $2.3 trillion has been spent, according to the Watson Institute for International and Public Affairs at Brown University.

Like Afghanistan’s future, whether the conflict was worth the cost remains unclear.

The Associated Press contributed.