The Queen and members of the royal family, including Prince William and Kate Middleton, joined army top brass and relatives of British soldiers who died in Afghanistan at a commemoration service at St Paul's Cathedral in London, marking the end of 13 years of British military operations in the country.

queen prince philip holding hands
The Queen and Prince Philip hold hands as they walk down the stairs of St Paul's Cathedral after a Service of Commemoration for troops who were stationed in AfghanistanChris Jackson/Getty Images
kate and prince william
Prince William and Kate Middleton depart the Service of CommemorationChris Jackson/Getty Images
kate and prince william
Kate Middleton's second child appears to kick as she and Prince William stand on the steps of St Paul'sChris Jackson/Getty Images
Afghanistan service
Prince William, Duke of Cambridge, Prince Harry and Catherine, Duchess of CambridgeChris Jackson/Getty Images
Afghanistan service
Camilla, Duchess of Cornwall, Catherine, Duchess of Cambridge and Prince Charles, Prince of Wales depart a Service of CommemorationChris Jackson/Getty Images
Camilla, Duchess of Cornwall
Camilla, Duchess of CornwallChris Jackson/Getty Images
Sophie, Countess of Wessex
Sophie, Countess of WessexChris Jackson/Getty Images
Afghanistan service
Prince Edward, Earl of Wessex and Prince Andrew, Duke of York attend a commemoration service to mark the end of combat operations in Afghanistan at St Paul's CathedralJohn Stillwell/Pool
Afghanistan service
Sophie, Countess of Wessex, Prince Edward, Earl of Wessex, Prince Andrew, Duke of York, Prince William, Duke of Cambridge and Britain's Catherine, Duchess of Cambridge, leave St Paul's CathedralBen Stansall/AFP

Also present was the Queen's grandson Prince Harry, who served two tours of duty in Afghanistan.

During the service, the Archbishop of Canterbury, spiritual head of the Church of England, blessed a cross made of shell casings that previously adorned a memorial wall at Camp Bastion, the main hub of the British military in Afghanistan.

Afghanistan service
The Queen and members of her family take part in a Service of Commemoration for troops who were stationed in AfghanistanKirsty Wigglesworth/Pool
Afghanistan service
A cross made from used artillery shell cases is brought to the altar by servicemenJohn Stillwell/Pool
Afghanistan service
The Queen meets Josh Campbell, formerly of the Royal Logistics Corps who lost both legs in an IED strike in AfghanistanKirsty Wigglesworth/Pool
Afghanistan service
An injured serviceman attends the memorial serviceJohn Stillwell/Pool

Also among the congregation was Tony Blair, who as prime minister in 2001 took Britain into the US-led coalition that invaded Afghanistan and toppled the Taliban government in response to the September 11 attacks on New York and Washington.

Tony Blair Gordon Brown
Former prime ministers Tony Blair and Gordon BrownBen Stansall/AFP
Afghanistan service
David Cameron attends the Service of CommemorationJeremy Selwyn/Pool
Afghanistan service
Deputy prime minister Nick Clegg and leader of the opposition Ed MilibandJeremy Selwyn/Pool

Britain lost 453 servicemen and women in Afghanistan out of the 140,000 who served there over the years. The last combat troops left in October last year, leaving behind only about 500 trainers and advisers assisting the Afghan security forces.

The government says the long war stopped Afghanistan from being used as a safe haven for militants to plan attacks on British streets, and that Afghanistan is now a safer and more prosperous country than it was before.

However, the war remains controversial in the eyes of some Britons, who say its objectives were not articulated clearly enough and Britain paid too high a price for what was achieved.

Afghanistan service
A wounded serviceman arrives for the service of commemoration at St Paul'sStefan Wermuth/Reuters
Afghanistan service
A young boy wearing medals arrives for the Afghanistan service of commemoration at St Paul's CathedralStefan Wermuth/Reuters

The service was followed by a military parade through the City of London and a flypast of aircraft used in the campaign, including Chinook, Apache and Sea King helicopters and Hercules and Tornado airplanes.

Afghanistan British troops
A Royal Air Force Chinook flies over London during a Service of Commemoration for troops who were stationed in AfghanistanCarl Court/Getty Images
Afghanistan service
Members of the royal family, politicians, military personnel and other guests gather outside St Paul's Cathedral for the flypastBen Stansall/AFP
Afghanistan service
Service-goers watch a flypast outside St Paul's CathedralChris Jackson/Getty Images