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.

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.

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.

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.

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.