The Taliban have seized power in Afghanistan two weeks before the U.S. was set to complete its troop withdrawal after a costly two-decade war.

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.

Taliban fighters take control of Afghan presidential palace after the Afghan President Ashraf Ghani fled the country, in Kabul, Afghanistan, Sunday, Aug. 15, 2021. Person second from left is a former bodyguard for Ghani. (AP Photo/Zabi Karimi)

Taliban fighters take control of Afghan presidential palace after the Afghan President Ashraf Ghani fled the country, in Kabul, Afghanistan, Sunday, Aug. 15, 2021. Person second from left is a former bodyguard for Ghani. (AP Photo/Zabi Karimi)

Here's a look at what happened 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 U.S.-led invasion of Afghanistan in 2001 ousted the insurgents from power, but they never left. 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.

Taliban fighters poses for a photograph while raising their flag Taliban fighters raise their flag at the Ghazni provincial governor's house, in Ghazni, southeastern, Afghanistan, Sunday, Aug. 15, 2021. (AP Photo/Gulabuddin Amiri)

Taliban fighters poses for a photograph while raising their flag Taliban fighters raise their flag at the Ghazni provincial governor's house, in Ghazni, southeastern, Afghanistan, Sunday, Aug. 15, 2021. (AP Photo/Gulabuddin Amiri)

WHY ARE PEOPLE FLEEING THE COUNTRY?

They're worried that the country could descend into chaos or the Taliban could carry out revenge attacks against those who worked with the Americans or the government.

Many also fear the Taliban will reimpose the harsh interpretation of Islamic law that they relied when they ran Afghanistan from 1996 to 2001. Back then, women were barred from attending school or working outside the home. They had to wear the all-encompassing burqa and be accompanied by a male relative whenever they went outside. The Taliban banned music, cut off the hands of thieves and stoned adulterers.

The Taliban have sought to present themselves as a more moderate force in recent years and say they won't exact revenge, but many Afghans are skeptical of those promises.

Travelers enter in Pakistan through a border crossing point in Chaman, Pakistan, Monday, Aug. 16, 2021. A special flight of Pakistan’s national airline PIA has arrived in Islamabad carrying 329 passengers from Kabul, and another carrying 170 people will arrive later today. A spokesman for the airline said Saturday that the airline will operate three flights tomorrow to transport Pakistanis and other nationalities looking to leave Kabul. (AP Photo/Jafar Khan)

Travelers enter in Pakistan through a border crossing point in Chaman, Pakistan, Monday, Aug. 16, 2021. A special flight of Pakistan’s national airline PIA has arrived in Islamabad carrying 329 passengers from Kabul, and another carrying 170 people will arrive later today. A spokesman for the airline said Saturday that the airline will operate three flights tomorrow to transport Pakistanis and other nationalities looking to leave Kabul. (AP Photo/Jafar Khan)

WHY ARE THE TALIBAN TAKING OVER NOW?

Probably because U.S. troops are set to withdraw by the end of the month.

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.

REBECCA GRANT: BIDEN'S AFGHANISTAN HORROR - DON'T BLAME OUR MILITARY, BLAME BLINKEN, BIDEN, SENATE DEMS

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.

Taliban fighters patrol inside the city of Kandahar, southwest Afghanistan, Sunday, Aug. 15, 2021. (AP Photo/Sidiqullah Khan)

Taliban fighters patrol inside the city of Kandahar, southwest Afghanistan, Sunday, Aug. 15, 2021. (AP Photo/Sidiqullah Khan)

WHY DID THE AFGHAN SECURITY FORCES COLLAPSE?

The short answer? Corruption.

The U.S. and its NATO allies spent billions of dollars over two decades to train and equip Afghan security forces. But the Western-backed government was rife with corruption. Commanders exaggerated the number of soldiers to siphon off resources, and troops in the field often lacked ammunition, supplies or even food.

Their morale further eroded when it became clear the U.S. was on its way out. As the Taliban rapidly advanced in recent days entire units surrendered after brief battles, and Kabul and some nearby provinces fell without a fight.

A Taliban fighter stands guard at the main gate leading to the Afghan presidential palace, in Kabul, Afghanistan, Monday, Aug. 16, 2021. The U.S. military struggled to manage a chaotic evacuation from Afghanistan on Monday as the Taliban patrolled the capital and tried to project calm after toppling the Western-backed government. (AP Photo/Rahmat Gul)

A Taliban fighter stands guard at the main gate leading to the Afghan presidential palace, in Kabul, Afghanistan, Monday, Aug. 16, 2021. The U.S. military struggled to manage a chaotic evacuation from Afghanistan on Monday as the Taliban patrolled the capital and tried to project calm after toppling the Western-backed government. (AP Photo/Rahmat Gul)

WHAT HAPPENED TO THE PRESIDENT OF AFGHANISTAN?

He fled.

WHITE HOUSE WALKS BACK BIDEN'S FAILED PREDICTIONS ABOUT AFGHANISTAN WITHDRAWAL

President Ashraf Ghani hunkered down and made few public statements as the Taliban swept across the country. On Sunday, as they reached the capital, he left Afghanistan, saying he had chosen to leave to avoid further bloodshed. It's not clear where he went.

People try to get into Hamid Karzai International Airport in Kabul, Afghanistan August 16, 2021. REUTERS/Stringer NO RESALES. NO ARCHIVES     TPX IMAGES OF THE DAY

People try to get into Hamid Karzai International Airport in Kabul, Afghanistan August 16, 2021. REUTERS/Stringer NO RESALES. NO ARCHIVES     TPX IMAGES OF THE DAY

WHY ARE PEOPLE COMPARING AFGHANISTAN TO THE FALL OF SAIGON?

The Fall of Saigon to North Vietnamese forces in 1975 marked the end of the Vietnam War. It became an enduring symbol of defeat after thousands of Americans and their Vietnamese allies were airlifted out of the city on helicopters. U.S. Secretary of State Antony Blinken has rejected any comparisons to Afghanistan, saying: "This is manifestly not Saigon."

FORMER AFGHAN ADVISER TO MILITARY SAYS US ‘HANDLED EVERYTHING OVER TO THE TALIBAN’

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.

Hundreds of people run alongside a U.S. Air Force C-17 transport plane, some climbing on the plane, as it moves down a runway of the international airport, in Kabul, Afghanistan, Monday, Aug.16. 2021. Thousands of Afghans have rushed onto the tarmac at the airport, some so desperate to escape the Taliban capture of their country that they held onto the American military jet as it took off and plunged to death. 

Hundreds of people run alongside a U.S. Air Force C-17 transport plane, some climbing on the plane, as it moves down a runway of the international airport, in Kabul, Afghanistan, Monday, Aug.16. 2021. Thousands of Afghans have rushed onto the tarmac at the airport, some so desperate to escape the Taliban capture of their country that they held onto the American military jet as it took off and plunged to death.  (Verified UGC via AP)

WHAT DOES THE TALIBAN TAKEOVER MEAN FOR WOMEN?

Many fear it could mean a severe rollback of rights.

Afghan women have made major gains since the overthrow of the Taliban. Many are worried they will once again be confined to their homes. The Taliban have said they are no longer opposed to women attending school but have not set out a clear policy on women's rights. Afghanistan remains an overwhelmingly conservative country, especially outside major cities, and the status of women often varied, even under Taliban rule.

A man pulls a girl to get inside Hamid Karzai International Airport in Kabul, Afghanistan August 16, 2021. REUTERS/Stringer  NO RESALES. NO ARCHIVES     TPX IMAGES OF THE DAY

A man pulls a girl to get inside Hamid Karzai International Airport in Kabul, Afghanistan August 16, 2021. REUTERS/Stringer  NO RESALES. NO ARCHIVES     TPX IMAGES OF THE DAY

WILL THE TALIBAN ONCE AGAIN HARBOR AL-QAIDA?

That's anyone's guess, but American military officials are worried.

In the peace deal signed with the United States last year, the Taliban pledged to fight terrorism and prevent Afghanistan from again becoming a base for attacks. But the U.S. has little leverage to enforce that.

AFGHAN AMERICANS RALLY OUTSIDE WHITE HOUSE, BLAME BIDEN FOR DEBACLE

Technological advances over the last 20 years allow the United States to target suspected militants in countries like Yemen and Somalia where it does not have a permanent troop presence. The Taliban paid a heavy price for their role in the Sept. 11 attacks and likely hope to avoid a repeat as they seek to consolidate their rule.

But earlier this year, the Pentagon’s top leaders said an extremist group like al-Qaida may be able to regenerate in Afghanistan, and officials are now warning that such groups could grow much faster than expected.

CLICK HERE TO GET THE FOX NEWS APP  

Afghanistan is also home to an Islamic State group affiliate that has carried out a wave of horrific attacks targeting its Shiite minority in recent years. The Taliban have condemned such attacks and the two groups have fought each other over territory, but it remains to be seen whether a Taliban government will be willing or able to suppress IS.