The Taliban, which was on the brink of total victory in Afghanistan on Sunday, previously governed the country between 1996 and 2001, imposing a strict interpretation of Islamic sharia law before being ousted and launching an insurgency.
Here is some background on the movement:
The Taliban originated among young Afghans who studied in Sunni Islamic schools called madrassas in Pakistan after fleeing Afghanistan during the 1979-1989 Soviet occupation.
They take their name from talib, the Arabic word for student.
In the early 1990s, with Afghanistan in the chaos and corruption of civil war, the Taliban was formed in the southern province of Kandahar under the leadership of one-eyed warrior-cleric Mullah Omar.
Omar, who led them until his death in 2013, was from a stronghold of the powerful Pashtun ethnic group from which most Taliban fighters come.
Haibatullah Akhundzada is now the top leader, while Taliban co-founder Mullah Baradar heads the political wing.
Dramatic rise to power
Promising to restore order and justice, the Taliban rose dramatically.
They drew substantial support from Pakistan and initially had the tacit approval of the United States.
In 1994 they seized the city of Kandahar almost without a fight.
Equipped with tanks, heavy weapons and the cash to buy the support of local commanders, they steadily moved north, before capturing the capital Kabul on September 27, 1996.
President Burhanuddin Rabbani had already fled.
Taliban fighters dragged former communist president Mohammed Najibullah from a United Nations office where he had been sheltering, and hanged him in a public street after torturing him.
Reign of terror
The Taliban government imposed the strictest interpretations of sharia, establishing religious police for the suppression of "vice".
Music, television and popular pastimes such as kite-flying were banned. Girls' schools were closed, while women were prevented from working and forced to wear an all-covering burqa in public.
Taliban courts handed out extreme punishments including chopping off the hands of thieves and stoning to death women accused of adultery.
By 1998, they had control of 80 percent of the country, but were only recognised as the legal government by Pakistan, the United Arab Emirates, and Saudi Arabia.
In 2001 they blew up 1,500-year-old giant statues of the Buddha in the central Bamiyan valley.
Mullah Omar was based mostly in Kandahar where he lived in a house reportedly built for him by Osama bin Laden.
The Taliban allowed Afghanistan to become a sanctuary for Al-Qaeda, which set up training camps.
The September 11, 2001 attacks that killed around 3,000 people in the US were immediately blamed on Al-Qaeda.
Accusing the Taliban of refusing to hand over Bin Laden, the US and allies launched air strikes on Afghanistan in October.
By early December the Taliban government had fallen, its leaders fleeing to their strongholds in the south and east, or across the border into Pakistan's tribal zone.
At first written off as a spent force, the Taliban rebuilt to lead an insurgency against the new Western-backed government.
Making heavy use of improvised bombings and suicide attacks, they labelled as "crusaders" the tens of thousands of foreign troops who deployed into the country as part of a US-dominated NATO force.
The NATO combat mission ended in December 2014 and the bulk of Western forces withdrew.
In July 2015 Pakistan hosted the first direct talks between Afghan and Taliban leaders, with support from China and the US, but they collapsed after Mullah Omar's death was revealed.
The rival Islamic State jihadist group emerged in Afghanistan in 2015, launching its own series of devastating attacks, mainly on Kabul.
US exit, Taliban offensive
In 2018 the US and Taliban began discreet talks in Doha, that were interrupted several times after attacks against American troops.
A historic deal was signed by the US with the Taliban in Doha on February 29, 2020, laying out a timetable for a full American troop withdrawal.
On July 6, 2021, the US military said it had completed 90 percent of its retreat from Afghanistan.
Five weeks later, the Taliban are on the outskirts of the capital Kabul, and the government has conceded it is preparing for a "transfer of power".