Joe Biden will take over as president from Donald Trump on 20 January with the USA in the midst of its second or maybe third attempt to extricate itself from Afghanistan.
After the 11 September 2001 Al Qaeda attack on the World Trade Centre in New York, the USA sent troops and support to help Northern Alliance warlords in Afghanistan to drive out the Taliban, which then controlled most of the country and provided a reserve base for Al Qaeda.
The Northern Alliance won quickly. The Taliban abandoned the capital city, Kabul, which they had ruled since 1996, before Northern Alliance troops even got there, and the people poured onto the streets to cheer.
There were only a couple of thousand US troops in the country then. After military mopping-up, by May 2003 Donald Rumsfeld, Secretary of Defence for US president George W Bush, declared an "end to major conflict" in Afghanistan.
Yet the Taliban had regrouped in areas of north-west Pakistan largely outside the control of Pakistan's government. It had support from some elements at least of Pakistan's military. From the US invasion of Iraq in March 2003, it went back on the offensive and regained ground.
Bush increased the US military presence, bit by bit, to about 30,000. Barack Obama became president in January 2009 with a policy of pulling US troops out of Iraq, but putting extra troops into Afghanistan.
He suggested that he wanted something like the US troop "surge" in Iraq in 2007, which did have military success against the Sunni-sectarian resistance, though only to stabilise a Shia-Islamist regime in Baghdad which was closer to Iran than to the USA. That Baghdad regime, by its Shia bias and its corruption, would create the conditions for the Sunni-sectarian resistance to regroup around Daesh and take Mosul and much of northern Iraq in June 2014.
As Obama's vice-president, Joe Biden announced early in 2009 that Washington was conducting a “strategic review” on Afghanistan with a view to setting “clear and achievable” goals. An official told The Guardian that the US would now be "much more realistic", and that for the US to withdraw Afghanistan "doesn’t need to be a democracy, just secure".
In 2014 the US and NATO officially handed over responsibility to the Afghan army, and stepped back to an advisory and supplementary role. But the "surge" in Afghanistan, in which the US military presence had risen to over 100,000 by 2010, had had not even the limited and short-term success the 2007 US "surge" in Iraq had had. High civilian casualties and the corruptness of the Kabul government drove people in rural Afghanistan towards the Taliban.
And the costs were huge. The US's military spending on Afghanistan was $120 billion in 2011, and over 2001-20 has been maybe $800 billion. Its total related spending, maybe $2,000 billion over those 20 years. With essentially nothing to show for it.
Obama turned to winding down and hoping for the best. He announced a plan to withdraw completely by 2016. At the end of his term of office there were still 8,400 US troops in Afghanistan, and Obama said he would leave it to his successor to decide what next.
Donald Trump took office promising to withdraw from Afghanistan, but initially increased troop numbers to 17,000.
In 2019-20 he made another drive to get out, more or less anyhow. In February 2020 the USA signed a peace deal with the Taliban over the heads of the Afghan government. From September 2020 the USA finally strong-armed the Kabul government and "civil society representatives" into faltering direct talks with the Taliban.
There are now around 4,000 US troops in Afghanistan (in a total of 11,000 NATO troops, in contingents from 38 countries), and Trump officials say they plan to have that number down to 2,500 by mid-January.
One condition in the February 2020 agreement was that the Taliban would not attack US troops: it hasn't, but then those troops have been keeping out of harm's way. Another was that the Taliban would break links with Al Qaeda. It hasn't done that, though it has clashed with Daesh, which is now also organising in Afghanistan, at odds with both the Taliban and Al Qaeda.
The US is keen to get out. Asked in July 2020 whether rapid withdrawal would indict the US as responsible for the Taliban regaining power, Joe Biden replied: "Zero responsibility. The responsibility I have is to protect America's national interest and not put our women and men in harm's way... that's what I'd do as president".
It will probably not be so simple. Pakistan may be happy with the Taliban regaining power, but all the other important powers, including China, Russia, India, Iran, want a deal which limits the Taliban. On the other side, the Taliban is probably stronger than ever. It has 60,000 full-time fighters, and a solid economic base in the opium trade from the areas it controls. In the absence of any credible alternative social programme, its religio-political programme grips people, or enough people to keep it strong. Attacks in Kabul, whether from Daesh or from covert Taliban operators, have increased. On 2 November 2020, an Islamist attack on the Kabul University campus killed 20-odd or 30-odd students; on 15 December the deputy governor of Kabul was killed by a car bomb.
On all indications, the Taliban will continue its war despite all talks and agreements, seeing no reason to stop short of fully regaining power.
It is not certain it can do that. Before 2001, it never gained control of the whole country. The old Stalinist (PDPA) government in Kabul, under Mohammad Najibullah, held on to the city for three years after USSR troops withdrew in 1988-89, and was defeated (initially by a looser Islamist alliance, to be supplanted by the Taliban in 1996) only after Russia withdrew all aid in January 1992. Kabul now has a population of over 4 million. Even if most of them have no memory of the Taliban's rule in Kabul in 1996-2001 (42% of Afghanistan's population is under 14, and Kabul's population was down to 500,000 in 2001), the vast majority will fear and oppose Taliban reconquest.
But the US presence, despite all the billions spent, has been maybe even less successful in nurturing a substantial and coherent modernising force in Afghan society than the USSR's disastrous war in 1979-1989 was. Solidarity has for many years supported US withdrawal from Afghanistan. But not because it will be liberation if the Taliban win, or because the US presence can be accurately described as colonial or semi-colonial. No: the longer the US stays, the worse the prospects for after its withdrawal, inevitable some day, become. Only a working-class and democratic upheaval in Pakistan, cutting off the Taliban from its nurturing hinterland, could change that calculus.
Some statistics look impressive. Most people in Afghanistan now have at least some electricity. Primary school enrolments, only about 20% of the age-group in 2001, are near 100%, on paper at least. GDP per head (purchasing-power-parity figures) has risen from $877 in 2001 to $2293 in 2019. The Afghan army, built largely from scratch after 2001, is now 180,000 strong (with more generals, apparently, than the US army).
But the judgement of a 2012 report on the economy still rings true: "Afghanistan [outside the subsistence-level agriculture still widespread in the rural majority of the population] has a service economy concentrated on cosmetic projects mainly driven by the donor community" (75% of the government's budget comes from international aid). "It lacks a long-term strategy... Thirty years of war and conflict have destroyed the minimal economic infrastructure and institutions this country once possessed... No efforts have been made to either reinstate the economic structure of the past, or to develop new ones that can help build a modern state and developed economy. Instead, energy is wasted on projects and activities in the name of privatisation and the free market, which have brought more harm than benefit to the country and the economy".
Although the country is estimated to have large mineral wealth, it has almost no exports beyond fruit and nuts to India and Pakistan. Unemployment is steadily 20-odd%. The country has more educated young people than it had, but they emigrate, scratch jobs in international-donor projects, or languish unemployed and discontented.
The presidential election of September 2019 drew only 1.8 million voters, out of 10 million registered. The result was not announced until February 2020, and then was rejected by the leading candidates, opening a crisis resolved only by them agreeing a power-sharing deal (as they had done after the previous election in 2014).
The Afghan feminist Malalai Joya puts it like this:
"Just 19 years ago, the Americans and NATO, under the name of 'Fight against Terrorism', occupied our country. Their first work was to suppress the Taliban's medieval Emirates, but after two decades of killing and crimes [they have turned] Afghanistan into a ruined village...
"From what is going on under the name of the so-called peace efforts in Doha [the talks between the Taliban and the Afghan government and "civil society"], expect every betrayal... except peace!"