Queen Elizabeth joined veterans of the Afghan war and relatives of those who died, at commemorations in London marking the end of Britain’s involvement.
A service was held at St Paul’s Cathedral, accompanied by military flypast and a procession in London ahead of a reception at Guildhall.
The Prime Minister David Cameron gave a reading from the Bible.
Prince Harry, who did two stints as a soldier in Afghanistan, was among several royals present.
Similar services have been held elsewhere in the UK, in Germany, and in Afghanistan.
Earlier, the Afghan President Ashraf Ghani paid tribute to the 453 UK troops who died, saying they paid the “ultimate sacrifice”.
Many more British soldiers were wounded in the conflict, which began when the US-led coalition invaded Afghanistan to topple the Taliban after the September 11 attacks.
Some relatives of British victims have said much has improved in the country – though one mother of a dead soldier stressed that Afghans were still losing their lives because of the Taliban.
The last combat troops left in October after a 13-year presence. NATO ended its mission in December. About 500 UK personnel remain to advise and train Afghan forces.