The Taliban have taken control of Afghanistan, with the country's capital Kabul falling under their power.
British troops started arriving in the Afghan capital on August 14 and 15, as part of Operation Pitting to help the rescue of UK nationals and staff.
The Western withdrawal of military personnel was nearing completion when the Taliban took Kabul on Sunday, 15 August.
President Joe Biden announced in July that the American military mission in Afghanistan would end on 31 August, concluding almost 20 years of operations in the country.
Here's a detailed look at some of the most recent developments in the country.
27 August, 'Hours' Remain In UK's Kabul Evacuation Mission
The UK's evacuation effort in Kabul has entered its final stages, but has not been reduced by the terror attack near the city's airport, the Defence Secretary said.
Ben Wallace said there were just "hours" left in the UK's mission to help people evacuate the country after closing the main processing site – near where the bombs were detonated.
"We closed the Baron Hotel almost exactly on schedule. The explosion was horrendous, but it didn't hasten our departure," he told Sky News.
Despite airlifting nearly 14,000 people out of Afghanistan in the past two weeks, Mr Wallace said "the sad fact is not every single one will get out".
Mr Wallace declined to give a timeline for the exit of British forces.
However, he said it would come before the American withdrawal – with Joe Biden having set a departure date for Tuesday 31 August.
27 August, 95 Afghans Killed In Kabul Airport
At least 95 Afghans were killed in the suicide bombings outside Kabul's international airport, officials said.
Afghan and US officials had earlier said the bombings killed at least 60 Afghans and 13 US troops, in the deadliest day for US forces in Afghanistan since August 2011.
The US government said further attempted attacks are expected ahead of the Tuesday deadline for foreign troops to leave, ending America's longest war.
Watch: Afghanistan – PM says UK Kabul evacuations will go on despite 'barbaric' deaths.
26 August, US Troops Among Dead After Explosions Near Kabul Airport
US service personnel and Afghans were killed in explosions near Kabul airport.
The two blasts happened at the Abbey Gate and near the Baron Hotel, as western forces continued their evacuation missions from Afghanistan.
Marine Corps General Kenneth McKenzie, commander of US Central Command, told a news conference: "At this time we know that 12 US service members have been killed in the attack, and 15 more service members have been injured.
"A number of Afghan civilians were also killed and injured in the attack."
The Ministry of Defence (MOD) has said there are no reported UK military or UK Government casualties.
26 August, Thousands Of At-Risk Afghans Struggle To Reach Airport As Evacuation Continues
The US said as many as 1,500 Americans may have been awaiting evacuation from Afghanistan as threats of terrorist attacks targeting Kabul airport continued to grow.
Thousands of at-risk Afghans are struggling to get into the airport even as many thousands of other Afghans had already been flown to safety in nearly two weeks of round-the-clock flights.
The airlift continued on Thursday despite warnings of vehicle-borne bomb threats near the airport.
Watch: Afghanistan – multiple casualties in 'at least' two explosions near Kabul airport.
26 August, ISIS Attack In Kabul Could Happen 'Within Hours', Armed Forces Minister Says
The Armed Forces Minister warned an attack from ISIS could happen in Kabul within "hours".
As the US, UK and other NATO allies continued the evacuation of Kabul airport, a threat is said to have emerged from the less well-known terrorist group, ISIS-K.
The stark warning came as the Government changed travel advice to and from Afghanistan on Wednesday night.
Speaking to LBC on Thursday morning, Mr Heappey was asked whether the imminence of an attack could be measured in days.
He replied bluntly: "Hours. Hence the urgency of changing the travel advice last night.
"I was given lines today for what might happen if the attack happened while I was doing this media round."
24 August, US Troops Won't Stay Past 31 August
Boris Johnson and other G7 leaders failed to persuade US President Joe Biden to keep troops in Afghanistan beyond 31 August.
Following an emergency meeting of G7 leaders, chaired by the PM on Tuesday afternoon, Mr Biden said the deadline remained in place.
“We will go right up until the last minute that we can but you've heard what the President of the United States has said, you've heard what the Taliban have said," Mr Johnson said.
"We're confident we can get thousands more out, but the situation at the airport is not getting any better."
Watch: Afghanistan – who are ISIS-K?
23 August, Evacuation 'Down To Hours, Not Weeks'
The Defence Secretary said the evacuation of British nationals and former Afghan staff is "down to hours now, not weeks".
Ben Wallace said if the US extends its timetable "even by a day or two, then that will give us a day or two more to evacuate people"
Mr Wallace said the US has provided "the framework" to allow the UK withdrawal and when the Americans leave Kabul, "we will have to go as well".
"I don't think there is any likelihood on staying on after the United States," he said.
23 August, PM To Push Biden For Delay To 31 August Exit
Prime Minister Boris Johnson was expected to use an emergency G7 meeting to push US President Joe Biden to extend the Kabul evacuation deadline.
Speaking to Sky News, Taliban spokesperson Dr Suhail Shaheen said 31 August, the original date set by US President Joe Biden for the completion of the drawdown, is a "red line".
"If the US or UK were to seek additional time to continue evacuations – the answer is no. Or there would be consequences.
It comes as Prime Minister Boris Johnson is expected to use an emergency G7 summit to follow up on the UK's push for President Biden to extend the Kabul evacuation deadline.
Watch: Panjshir Valley – Afghanistan's last stand against the Taliban.
22 August, MOD Confirms Seven Dead In Crush At Kabul Airport
"Conditions on the ground remain extremely challenging but we are doing everything we can to manage the situation as safely and securely as possible,” a spokesman said.
It came as Defence Secretary Ben Wallace says "no nation will be able to get everyone out".
Writing in the Mail on Sunday, he said: "If the US timetable remains, we have no time to lose to get the majority of the people waiting out.
"Perhaps the Americans will be permitted to stay longer, and they will have our complete support if they do."
He added that the UK was looking at "ways to keep a presence in the country after the military are gone" as there was still a lot to do to "ensure conditions are right" but gave no further details.
19 August, Evacuation Is 'Humanitarian Disaster' Getting 'Worse And Worse' Each Day
A former Royal Marine based in Afghanistan told Forces News the evacuation of British nationals and former Afghan staff is a "humanitarian disaster that is just getting worse and worse every day".
Paul 'Pen' Farthing founded Nowzad, an animal rescue charity in Afghanistan, and told Forces News the evacuation process from Kabul "is broken".
"I'm not going to tolerate hearing another minister on TV saying the system is working because it's not," he said.
"Something needs to be done today otherwise more people will die and that is squarely on the hands of the British and the American governments."
He also said everything the UK Armed Forces have done over the last 20 years in Afghanistan is now "gone".
"Everything that everybody sacrificed is for nothing, absolutely nothing, and it's heartbreaking."
Watch: Why this Royal Marine veteran is refusing to leave Afghanistan.
19 August, UK Sends In More Troops And Set To Stay As Long As US Military Is '"Running" Airport
Speaking to the BBC, Ben Wallace said he had "just authorised another company" to deploy to Kabul.
He also said "if the US stay", it provides the chance to continue evacuating British nationals and former Afghan staff from Kabul, Afghanistan's capital.
"They're doing everything from the control tower to the firefighters, they are running that airport," he said.
"I've always said our scheme is open-ended and we're never going to close that scheme.
"So long, long after we are gone, whenever that is, we are starting to invest in third-country hubs already, so we can process people if they get out to other countries in the region."
Watch: Afghanistan – 'It's a devastating betrayal of anyone that's served in a British uniform', says Op Herrick veteran.
19 August, Taliban Mark Afghan Independence As Challenges To Rule Emerge
The Taliban celebrated Afghanistan's Independence Day by declaring it had beaten the United States.
But challenges to its rule, ranging from running the country's frozen government to potentially facing armed opposition, have begun to emerge.
From ATMs being out of cash to worries about food across the nation of 38 million people reliant on imports, the Taliban faces all the challenges of the civilian government it dethroned without the level of international aid it enjoyed.
Meanwhile, opposition figures fleeing to Afghanistan's Panjshir Valley talk of launching an armed resistance under the banner of the Northern Alliance, which allied with the US during the 2001 invasion.
18 August, Former Afghan President Meets With Taliban Faction Leader
Afghanistan's former president met with a senior leader of a powerful Taliban faction.
Former president Hamid Karzai and a senior official in the ousted government met with Anas Haqqani as part of preliminary meetings that a spokesman for Karzai said would facilitate eventual negotiations with the top Taliban political leader.
The US branded the Haqqani network a terrorist group in 2012, and its involvement in a future government could trigger international sanctions.
Watch: Afghanistan – UK 'collaborating' with Taliban in Kabul evacuation, Chief of Defence Staff says.
18 August, Protester Killed As Taliban Look To Tighten Control
The Taliban violently broke up a protest in eastern Afghanistan, killing at least one person as they quashed a rare public show of dissent.
Dozens of people gathered in the city of Jalalabad to raise the national flag a day before Afghanistan's Independence Day – commemorating the end of British rule in 1919.
They lowered the Taliban flag, a white banner with an Islamic inscription, that the militants have raised in the areas they captured.
Video footage later showed the Taliban firing into the air and attacking people with batons to disperse the crowd.
18 August, UK Speeds Up Kabul Evacuation Mission
The UK's ambassador to Kabul said officials were working to speed up the operation to evacuate the remaining UK nationals and their local allies out of Afghanistan.
Sir Laurie Bristow said the officials were putting "everything [they] can into getting British nationals and Afghans who worked with us in the past out of Afghanistan to safety".
"Yesterday we got about 700 people out," he said in a video posted on Twitter. "We are trying to scale up the speed and pace over the next couple of days.
"We will put everything we can on this for the next few days and try to get out everyone who we need to get to safety as soon as we can."
Watch: Emotional Defence Secretary admits 'some people won't get back' from Afghanistan.
18 August, UK 'Collaborating' With Taliban In Afghanistan
The Chief of the Defence Staff said UK personnel were "collaborating" with the Taliban to get people out of Afghanistan.
General Sir Nick Carter said there were "a lot of challenges on the ground" and "we hope to get around 1,000 people out today".
He also said he expected around seven aircraft to head to Kabul, Afghanistan's capital city, and told BBC Radio 4's Today programme "there are a lot of desperate people trying to get to the airport".
"Subject to the situation remaining calm, which the Taliban are working hard to achieve alongside us, the system will work, we believe," Sir Nick said.
"They are making sure that the centre of Kabul is very calm at the moment and so far we have not had reports of people finding it difficult to get to the airport."
16 August, Extra UK Troops And Aircraft To Support Kabul Evacuation Mission
This included an additional 200 troops being sent to Kabul, bringing the number of personnel deployed in the city, under the codename Op Pitting, to 900.
Additional personnel are being forward deployed to the region to be able to move into the country quickly if needed, while more personnel are being held at readiness in the UK.
Some Royal Air Force aircraft have also been diverted from other operations to support the repatriation flights.
16 August, Chaos As Civilians Cling To US Aircraft Leaving Kabul
A video published online appeared to show civilians clinging on to a US aircraft leaving Kabul Airport.
Senior US military officials say the chaos at the airport left seven people dead, including some who fell from a departing American military transport jet.
Watch: Afghanistan – chaos as civilians cling to US aircraft leaving Kabul.
16 August, Taliban 'In Control' Of Afghanistan
The Defence Secretary has acknowledged that the Taliban "are in control" of Afghanistan, saying there is a sense of sadness in the recent events.
Ben Wallace told Sky News: "You don't fix things overnight in global issues, you have to manage them.
"My job as defence secretary is to make sure that we protect not only the UK nationals, but those Afghans we have an obligation to, that is actually why we're in the country.
"For the last few weeks we've been in the country solely to process those people and to make sure we protect our officials doing that job and we'll continue to do so."
15 August, Taliban Fighters Enter Kabul
Afghan officials say the Taliban have entered Kabul.
The militant group had already seized all major cities apart from the capital, following the earlier collapse of Jalalabad, near a major border crossing with Pakistan.
President Joe Biden and other top US officials were said to be stunned by the pace of the Taliban's nearly complete takeover of Afghanistan, as the planned withdrawal of American forces urgently became a mission to ensure a safe evacuation.
14 August, Afghan President Defiant As Additional British Troops Deploy
Afghan President Ashraf Ghani said he will not give up the "achievements" of the last 20 years and that "consultations" are under way, during a televised address.
The announcement came as UK troops had already begun deploying on Operation Pitting, to assist with the evacuation of UK nationals and former British staff eligible for relocation under the Afghan Relocation and Assistance Policy (ARAP).
At this stage, the Taliban have captured much of northern, western and southern Afghanistan in recent weeks, leaving the Western-backed government in control of a smattering of provinces in the centre and east, as well as the capital, Kabul, and the northern city of Mazar-i-Sharif.
13 August, Taliban Take Four More Provincial Capitals, Including Lashkar Gah
The Taliban captured a further four provincial capitals in southern Afghanistan as their offensive gradually encircles Kabul, the country's capital.
Ataullah Afghan, head of the provincial council in Helmand, said the Taliban captured the provincial capital of Lashkar Gah after heavy fighting.
The loss of the city comes after years of blood spilled by US, British and NATO forces.
Hundreds of foreign troops were killed there over the course of the nearly two-decade war.
Atta Jan Haqbayan, the provincial council chief in Zabul province, said the local capital of Qalat fell to the Taliban and officials are in a nearby army camp preparing to leave.
Two legislators from Afghanistan's southern Uruzgan province said local officials have surrendered the provincial capital, Tirin Kot, to the Taliban.
And the head of the council in the western province of Ghor later said the city of Feroz Koh had fallen to the insurgents.