The insurgents stormed across the country, capturing all major cities in a matter of days, as Afghan security forces trained and equipped by the U.S. and its allies melted away.
On Monday, President Joe Biden defended the decision to withdraw troops, saying he was faced with a choice between sticking to a previously negotiated agreement to pull out this year or sending thousands more service members back into Afghanistan for a "third decade" of war.
With assistance from global security expert Hal Kempfer and reporting from The Associated Press, here's an explanation of the conflict, why the United States is withdrawing and what comes next.
What is happening in Afghanistan?
The Taliban, a militant group that ran the country in the late 1990s, have again taken control.
The United States invaded Afghanistan in 2001 after the Sept. 11 terrorist attacks, ousting the Taliban insurgents from power. But they never left the region.
After they blitzed across the country in recent days, the Western-backed government that has run the country for 20 years collapsed. Afghans, fearing for the future, are racing to the airport, one of the last routes out of the country.
"The Taliban have taken over the entire country," Kempfer says.
"The Afghan national forces just melted away. Didn't put up much resistance at all. The president of Afghanistan fled the country and the Taliban are in charge everywhere."
He noted that the Taliban are allowing the United States to evacuate their own personnel. There are also some 20,000 to 40,000 Afghan nationals who wish to leave the country because they worked with the U.S. and believe they are in danger.
The evacuation is happening quicker than expected because U.S. planners did not think the Taliban would move in so quickly as U.S. troops withdrew.
Who are the Taliban?
"The Taliban are a very fundamentalist Sunni Islamic group," Kempfer says. "It's a rough grouping of a lot of tribal elements around Afghanistan. Their collective commonality is the fact they are Sunni Muslims. They come out of the tradition of fighting the Soviets with the (guerilla fighters) mujahideen."
He notes that Pakistan's intelligence service contributed to the formation of the Taliban by giving them significant backing during the civil war in Afghanistan of the early 1990s.
Why is the United States leaving Afghanistan?
The U.S. has been trying to get out of Afghanistan, its longest war, for several years now.
American troops ousted the Taliban in a matter of months when they invaded to root out al-Qaida, which orchestrated the 9/11 attacks while being harbored by the Taliban. But it proved more difficult to hold territory and rebuild a nation battered by repeated wars.
As the U.S. focus shifted to Iraq, the Taliban began to regroup and in recent years took over much of the Afghan countryside.
Last year, then-President Donald Trump announced a plan to pull out and signed a deal with the Taliban that limited U.S. military action against them. President Joe Biden then announced that the last troops would leave by the end of August.
As the final deadline drew close, the Taliban began a lightning offensive, overrunning city after city.
Why is the Taliban taking over Afghanistan?
"They feel they represent the Afghan people, they represent Afghan culture," Kempfer says. "They feel they represent the dominant religion of Afghanistan. For all those reasons they feel they should rightfully be in charge."
What will happen next in Afghanistan?
It's not clear.
The Taliban say they want to form an "inclusive, Islamic government" with other factions. They are holding negotiations with senior politicians, including leaders in the former government.
They have pledged to enforce Islamic law but say they will provide a secure environment for the return of normal life after decades of war.
But many Afghans distrust the Taliban and fear that their rule will be violent and oppressive. One sign that worries people is that they want to rename the country the Islamic Emirate of Afghanistan, which is what they called it the last time they ruled.
The Associated Press contributed to this report.