The United States has been engaged in a war in Afghanistan since 7 October 2001 on the heels of 9-11, the attack on the World Trade Towers in Manhattan.
The US justified its invasion because the Twin Towers raiders, under the direction of Osama bin Laden, had trained their terrorists in Afghanistan. In addition, the Taliban refused to extradite OBL to the United States when we charged him with masterminding the 9-11 attacks. He was then living in Afghanistan.
We have been continuously at war during Operation Enduring Freedom – Afghanistan (2001-2014) and Operation Freedom’s Sentinel (2015-present). This has spanned the presidencies of George W Bush, Barack H Obama, and Donald J Trump.
George W Bush started it. Barack H Obama sustained it — sometime, reluctantly. Donald J Trump is trying to end it even if it means taking a huge blow to American prestige.
Initially a US operation (joined by the United Kindgom), the war became a NATO operation in 2003. Almost immediately, the US defeated the Taliban and their Al-Qaeda hosts using a coalition of Afghan warlords that became known as the Northern Alliance. The US provided leadership, Special Forces, and firepower in the form of artillery and air support.
In 2004, the Afghan people held an election which resulted in Hamid Karzai being anointed as President. Afghanistan was and is a narco-corrupt country.
The Taliban and other affiliated groups, operating from rebel strongholds and Pakistan, engaged in fierce guerrilla warfare that motivated the NATO allies to send as many as 140,000 troops (100,000 American included). This insurgency continued unabated with a crescendo in 2009. In 2009, clearly the Allies were winning, but hadn’t yet delivered a knock out punch. Pakistan was sheltering the Taliban during the winters, something that should never have been tolerated.
Then, the United States (President Obama) announced that its military commitment would end in December 2014 though it would maintain some military presence thereafter. [I consider this announcement to have been one of the worst public utterances by any warring nation in the history of warfare. The US, in effect, told the Taliban, “Uhhh, we are going home in December 2014,” to which the Taliban said to themselves, “What say you we spend the time between now and December 2014 in the south of France working on our tans?”]
In 2009, during the Obama administration, the US sent out the first peace feelers indicating the US would consider a negotiated settlement. Here is a pic of a loya jirga, the local deliberative body of tribal Afghanistan.