US forces have left their main military base in Afghanistan – the hub for a 20-year mission against the Taliban and al Qaeda – in the clearest sign yet America’s longest war is ending.

The sprawling Bagram airfield, about 40 miles north of Kabul, is being handed over to the Afghan security forces in a symbol of the US military’s departure from a battlefield that’s still raging, amid warnings of a looming civil war.

US President Joe Biden said earlier this year all of between 2,500 to 3,500 US troops in Afghanistan would leave by 11 September, the anniversary of the al Qaeda attacks on the United States in 2001 that prompted the US-led invasion in the first place.

However, it is clear the exit is happening at a much faster tempo, with expectations the majority of personnel will be out by around 4 July – this Sunday – as the US celebrates Independence Day.

A US official was quoted by the Associated Press as saying General Austin Miller, the top commander in Afghanistan, “still retains all the capabilities and authorities to protect the forces.”

Washington’s decision to leave by a calendar date regardless of the security conditions on the ground – which look increasingly dire – meant the end of a NATO operation also involving some 7,000 non-American forces, including 750 British service personnel.

Most have already returned home, with Germany and Italy announcing on Wednesday that their involvement had ended.

More on Afghanistan

Sky News understands the majority of UK troops have also left Afghanistan, with flag-lowering ceremonies taking place without fanfare.

Boris Johnson is set to chair a National Security Council meeting on Monday to decide the future shape of the UK footprint.

The US has refused to say when the last US soldier would leave Afghanistan, citing security concerns, but also the protection of Kabul’s international airport is still being negotiated.

Turkish and US soldiers are protecting the airport. That protection is currently covered under NATO’s Resolute Support Mission, which is the one being wound down.

Until a new agreement is negotiated between Turkey and the Afghan government, and possibly the United States, the NATO mission would appear to have to continue in order to give international troops the legal authority to be on the ground still.

The US will also have about 650 troops in Afghanistan to protect its embassy in Kabul. Their presence it is understood will be covered in a bilateral agreement with the government.

The Taliban welcomed the exit of US forces from Bagram airfield, once the site of a large US detention centre.

“We consider this withdrawal a positive step,” a Taliban spokesman told Reuters. “Afghans can get closer to stability and peace with the full withdrawal of foreign forces.”

The US-led exit comes as Taliban insurgents make strides in several parts of the country, overrunning dozens of districts and overwhelming beleaguered Afghan security forces.