The war for Afghanistan: Successes and setbacks
August 22, 2017America comes under attack
The September 11, 2001, attacks shocked the world and were denounced by Taliban Foreign Minister Wakil Ahmed Muttawakil. However, the group's leader Mullah Omar insisted that Osama bin Laden - believed to have been responsible for the terror act - was not responsible.
Washington demanded that the Taliban's Islamic Emirate of Afghanistan hand over Bin Laden, but was met with resistance.
The Taliban also refused to close al-Qaida training bases and hand over wanted al-Qaida officials other than Bin Laden.
Operation Enduring Freedom
The US, along with Britain, launched Operation Enduring Freedom on October 7, 2001, starting with air strikes. Taliban training camps and air defenses were targeted. US special forces were airlifted from Uzbekistan into the north of Afghanistan, where the Taliban already faced an armed opposition from the Northern Alliance.
Read more: Trump will own Afghan war in victory, his generals in defeat
The publicly-stated aim of the invasion, in the light of the 911 attacks, was to deny al-Qaida a base for its operations in Afghanistan.
The US forces planned the battle of Mazar-i-Sharif with Uzbek warlord General Dostum and, at the same time, began broadcasting in both Urdu and Pashto, the start of a psychological operation to win over "hearts and minds."
Taliban collapse
The US anticipated a tough battle for Mazar-i-Sharif that would last well into 2002, but the city fell swiftly.
Taliban forces also fled Kabul - precipitating an apparent Taliban collapse across the country. Rather than face the invaders directly, the Taliban and al-Qaida headed for the mountains and neighboring Pakistan, setting the scene for the long insurgency that continues to this day.
US and UK forces were still searching for the al-Qaida leadership into January 2002, but no sign emerged. Some 200 al-Qaida fighters were killed during the Battle of Tora Bora, but there was no sign of Bin Laden.
A new government
The Bonn agreement of December 2001 created the Afghan Interim Authority and the United Nations authorized an International Security Assistance Force (ISAF) with a mandate to help maintain security in Kabul and nearby areas.
Taliban and al-Qaida forces regrouped in the Shahi-Kot Valley area in early 2002, and sought to launch guerilla attacks copying the tactics of anti-Soviet fighters in the 1980s. The operation floundered initially, but hundreds of al-Qaida fighters were eventually killed, while many others escaped from Western forces.
Taliban fightback
The war in Iraq, which began in March 2003, meant there were fewer US Special Operations Forces to deploy to Afghanistan, although the number of ordinary US troops there rose to 16,000 by 2004.
The Taliban - noting that the US was distracted - looked to reassert itself. NATO assumed full command of ISAF as the insurgency, directed by the Pakistan-based Quetta Shura militant organization, gained momentum.
The insurgents increased their reliance on terror tactics, using suicide bombers and - in a method lifted from the insurgency in Iraq - improvised explosive devices.
President Hamid Karzai, who had been appointed interim leader after the invasion, won a democratic mandate in 2004 elections.
ISAF expansion
In October 2003, Germany sent Bundeswehr troops to the region of Kunduz, marking the first time that ISAF operated outside the Kabul area.
Western powers aimed to secure the country in a series of stages, initially moving north, then west, south and east.
By 2006, ISAF had taken responsibility for the entire country and there was an effort to crush a Taliban insurgency in the south. Operation Mountain Thrust was led by Afghan and Canadian forces, but it was largely unsuccessful with the Taliban appearing to have an inexhaustible supply of new fighters.
Control slipping away
From 2006, the Taliban made significant gains as ISAF struggled to hold the territory it had won. The violence escalated sharply from 2007 to 2009 and spread to the rest of the country. Fighting even crossed the border into Pakistan.
Read more: Donald Trump's Afghanistan strategy raises stakes
In the first five months of 2008, the number of US troops in Afghanistan rose by more than 80 percent and the surge continued. In September 2009, General Stanley McChrystal said he estimated that a successful counter-insurgency strategy would take 500,000 troops and five more years.
President Hamid Karsai - who was becoming increasingly critical of the high civilian death toll at the hands of Western powers - was re-elected in a vote deemed by observers to have been "generally fair" but "not free."
Surge in troops as US gets its man
In May 2011, the US was able to celebrate at least one success after US Navy Seals killed al-Qaida's bin Laden in an operation in the Pakistani city of Abottabad, where he was found to be in hiding.
The US used Hellfire missiles and drone strikes to target al-Qaida's support base in Pakistan. Such unauthorized interventions, which often resulted in civilian casualties, were protested by Islamabad.
Overall, 2011 saw the most attacks by insurgents since the war began.
The number of ISAF soldiers peaked in 2011, as US President Barack Obama tried to end the war. There were some 130,000 coalition troops by the end of the year, still well short of what McChrystal had said would be needed.
NATO's decision to leave
In November 2010, at a summit in Lisbon, NATO announced its plan for withdrawal and the handing over of security responsibilities to the Afghan National Army.
Australia, Georgia, Germany, Italy, Romania, Turkey, the UK and the US left troops behind. Germany provided up to 850 of the troops that would stay, with 11,000 US soldiers making up the bulk of the forces.
The key message from NATO governments - many aware of electorates tired of their counties' involvement in foreign wars - was that this was not a combat mission. This residual force was there to advise and train still-fledgling Afghan forces and provide limited counterterrorism support, including against the growing threat of Islamic State in Khorasan Province.
Coalition forces were, however, allowed to retaliate with force should they be attacked.
The Mother of all Bombs
In April, 2017, Donald Trump's administration dropped the Mother of All Bombs (MOAB) - its largest non-nuclear bomb - in eastern Afghanistan in an effort to destroy tunnel complexes used by IS in Khorasan. According to the US' own estimates, there were between 600 and 800 IS fighters in Afghanistan. The bomb was thought to have killed 36.
Meanwhile, the Taliban continued to pose a threat as Afghan security forces struggled with the task of preserving peace on their own. After the security handover, there were increasing attacks on the capital, Kabul. One, in May, targeted the German embassy and killed more than 150 people.