The end of the 13-year conflict was marked by a ceremony of commemoration at St Paul’s Cathedral where the Most Rev Justin Welby paid tribute to all those who served, leaving behind family, facing danger and suffering injury.
Almost 150,000 UK personnel were deployed to Afghanistan, and 453 British men and women died in the fight against the Taliban insurgency.
In his address the Archbishop said: “Today is a moment for us to say thank you: thank you to all who served, whatever your role.”
The Queen and Duke of Edinburgh led the nation in remembering their sacrifices, and the efforts of others, and sat at the head of the congregation which included the Prime Minister David Cameron, senior members of the royal family, leading military figures and veterans.
Archbishop Welby told those within St Paul’s: “ ‘Great is your faithfulness’ says the prophet Jeremiah, turning to God in a time of deep distress.
“As our nation honours at this service all of you who have served in Afghanistan - forces personnel and many others, alongside so many of other nations - I ask you to hear those same words today, reverberating around our land: great is your faithfulness. You know about faithfulness.”
He added: “We thank you for your faithfulness: you who left family behind, you who trained hard, you who did not turn from danger, you who suffered injury and you who risked yourselves to care for the injured.
“I’m told that each wounded person was supported by up to 80 others by the time they got home. Great is your faithfulness.
“We also thank those of you who stayed behind, who let your loved ones go: you who worried for their safety each day and took your phone to your bedside each night, you who lived with the pining of children, as well as your own fears. Great is your faithfulness.”
“And we honour the faithfulness of all those who gave up their lives to give peace and security for others.”
During the service the Archbishop rededicated a cross made of shell casings that adorned a memorial wall in the main Allied base in Afghanistan, Camp Bastion.
It forms part of a new Bastion Memorial Wall at the National Memorial Arboretum, Staffordshire.
Prayers were said for the fallen, civilians left behind while their loved ones served in Afghanistan, and for the people of the troubled Middle East country and its leaders.
Afghan president Ashraf Ghani told the BBC the 453 UK troops had “paid the ultimate sacrifice to enable us to live in freedom, in hope for peace, prosperity and dignity”.
Today’s commemoration comes after Tony Blair admitted that he had not foreseen just how long the struggle in Afghanistan would last when he first deployed troops in the wake of the 9/11 attacks.
In an interview with Forces TV, the former prime minister, who attended the service, said that even now it was not properly understood just how much more there was to be done.
“I think we have not yet understood the depth of this problem, the scale of it, and the need for a comprehensive strategy to deal with it,” he said.
“It is not just Islamic State in Iraq and Syria. It is happening day in and day out - there are thousands of people losing their lives every few weeks.”
He said he believed his decision to deploy British troops in Afghanistan had been justified, although he acknowledged that families who had lost loved ones may feel differently.
The “prayers of intercession” were said by members of the Armed Forces and veterans, some of whom had served in Afghanistan
Among them was Sarah Bushbye, a former Corporal in the Royal Army Medical Corps, who was awarded the Military Cross for disregarding her own safety amid “bullets cutting the air’’ to treat British and Afghan comrades after a bomb attack.
During the service the Prime Minister gave a reading from the bible, the introduction to Jesus’ Sermon on the Mount from the gospel of Matthew.
Among the congregation was the Duke of Edinburgh, Prince of Wales, Duchess of Cornwall, Duke of Cambridge, his heavily-pregnant wife Kate, and Prince Harry - who served two tours during the conflict.
The royal men all wore their military uniforms for the service while Camilla and Kate were dressed in dark outfits, Kate’s by designer Beulah.
Deputy Prime Minister Nick Clegg and Defence Secretary Michael Fallon were also present along with the Earl and Countess of Wessex and the Duke of Gloucester.
After the service a parade was staged through the City of London to the Guildhall where a reception was held for veterans and their families attended by the senior royals and Mr Cameron.
Crowds watched five detachments, made up of serving personnel from the Army, RAF, Royal Navy and the Royal Marines, with a sixth of up to 400 veterans from the conflict, march through London.
They were joined by military bands and pipes and drums, and Charles took the royal salute.
Aircraft from the campaign, including Chinook, Apache and Sea King helicopters, as well as Hercules transport planes and Tornado attack jets, roared over the parade in their own salute.