Media playback is unsupported on your device Media caption The Queen was joined at St Paul's Cathedral by veterans and families of British soldiers who died in the Afghanistan war

The Queen has been joined by many veterans at St Paul's Cathedral for a service commemorating the end of UK involvement in the Afghanistan war.

PM David Cameron gave a reading at the ceremony, which members of the Royal Family also attended.

A flypast and a parade by veterans also honoured British servicemen and women who fought and died in the 13-year conflict.

The Archbishop of Canterbury said it was "a moment for us to say thank you".

Simultaneous services were also held across the UK, in Afghanistan and Germany.

Earlier, Afghan president Ashraf Ghani paid tribute to the 453 UK troops who died in the conflict, saying they had "paid the ultimate sacrifice to enable us to live in freedom, in hope for peace, prosperity and dignity".

Image copyright PA Image caption Prince Harry, who served in the Afghanistan war, with the Duke and Duchess of Cambridge

Image copyright Getty Images Image caption This injured serviceman was among the congregation in St Paul's Cathedral

The Duke of Edinburgh, the Prince of Wales and Duchess of Cornwall, the Duke and Duchess of Cambridge and Prince Harry - who served two tours during the conflict - were also at the ceremony.

During the service the Archbishop of Canterbury, the Most Reverend Justin Welby, blessed a cross made of shell casings which had been on a memorial wall in Camp Bastion, the main allied base in Afghanistan.

The cross is being moved to the Royal British Legion's National Memorial Arboretum.

Image caption Princess Anne, Prince Edward and Prince Andrew were all at St Paul's

Image caption Prince Charles also joined his mother, the Queen, for the ceremony

The Dean of St Paul's, the Very Reverend Dr David Ison, gave thanks for the commitment of service personnel, aid agencies and support organisations in that country.

He also commemorated "with sorrow and regret" those who were killed and asked for prayer for the Afghan nation, calling for remembrance of the "danger which people in that great country continue to face today".

The service was followed by a military parade through the City of London to a reception at Guildhall, and a flypast of aircraft used in the campaign.

The aircraft included Chinook, Apache and Sea King helicopters and Hercules and Tornado aircraft.

Image copyright AFP Image caption A service of commemoration was held among British troops in Kabul

Dave Hart, who served and was injured in Afghanistan, said: "I think today really is primarily, for me, about the comrades who didn't come home.

"And those who have come back with injuries - be they physical or mental - and also for their families. It does feel like a closing of a chapter really."

Similar ceremonies have also been held at military bases and churches across the UK, as well as in Germany.

The event in Afghanistan at the Afghan National Officer's Academy was attended by 150 personnel and some Afghan dignitaries.

Image copyright Getty Images

At the scene

Caroline Wyatt, BBC religious affairs correspondent

In the cold spring sunlight, it was the mothers who stood out as they waited patiently in line to enter St Paul's - as all had waited patiently for news of their sons serving in Helmand - before receiving the call that all military families dread.

Many of the bereaved were dressed in black, but several mothers wore a blood-red knitted poppy, made by some of the mothers themselves to raise money for military charities for care of the wounded.

Few of the military families here had easy answers when asked about whether the war had been worth it.

For the bereaved, all said the pain of the loss of their son, husband or father would never go away, although for some, the grief eased with time, though the tears were never far away.

Waiting in line with them were the wounded, many bearing the obvious scars of combat, some in wheelchairs, others walking on the prosthetic limbs they have become accustomed to over many painful years.

They, too, hesitated when asked about the human cost of the campaign, saying only history could judge.

Image copyright EPA Image caption The Duke and Duchess of Cambridge and Prince Harry are seen watching the flypast after the service

Image copyright Getty Images Image caption Members of the Royal Marines marched through London's streets following the commemoration event

UK forces were part of a US-led coalition which invaded Afghanistan and toppled the ruling Taliban in 2001, following the 9/11 attacks in the US.

At the peak of the 13-year campaign the UK military had 9,500 troops and 137 bases in Helmand Province.

The UK ended its operations in October, while Nato finished its mission in December.

UK troops in Afghanistan 140,000 UK troops served £21.5bn Total operational cost 453 UK troops killed

108 died in 2009 - the worst year

470 mentors staying on MOD

Earlier, Sarah Adams - mother of Pte James Prosser who was killed in Afghanistan in 2009 - told the Today programme: "James believed in what he was doing, and I have to try to accept that, that he wanted to do that and believed he should be there. But as a mum, it's very difficult.

"We did achieve a lot but we didn't make it the safest place and it's still ongoing. Afghan people are still losing their lives because of the Taliban."

Former soldier Craig Gadd, now of Help for Heroes, lost his left leg after stepping on an improvised explosive device in Afghanistan.

He said: "Things happen. I feel very lucky that I only lost one leg. Some of my colleagues have injuries far worse than mine. I've done some amazing things since that day."

Image caption The prime minister gave a reading from the New Testament during the service at St Paul's

Image copyright Reuters Image caption Labour Party leader Ed Miliband was among the political figures to be seen at the ceremony

Lance Corporal James Ashworth was killed in Afghanistan in 2012 and posthumously awarded the Victoria Cross. His father Duane Ashworth said he believed the country was in a better position than it was before UK involvement.

"It's now for the forces that are there to continue that training with the Afghan forces and police, to make sure what our lads did does continue."

In an interview with Forces TV, former PM Tony Blair said: "I always felt that it was right and justified that we were there in Afghanistan, that we were fighting both to remove the Taliban and then to try and stabilise the country.

"But there is nothing that's really possible to say that could provide true consolation for the family of someone who has lost their life."

Media playback is unsupported on your device Media caption Tony Blair: "For all the challenges in Afghanistan there have been huge gains"

Defence Secretary Michael Fallon said: "Afghanistan has taught us these operations take time, you need to be patient, you need to help build resilience, you need to concentrate on developing and improving the economy of the country - as well as the military effort to defeat terrorism itself."

Some British combat troops still remain in Afghanistan in training, advisory and support roles.

Media playback is unsupported on your device Media caption Ghani: "British troops paid ultimate sacrifice to enable us to live in freedom"

As well as paying tribute to Britain's war dead, President Ghani spoke of the enduring legacy of the UK's commitment at the British-run officer training academy near Kabul.

BBC Afghanistan correspondent David Loyn said President Ghani's words contrast strongly with complaints by his predecessor President Karzai, who said that the British presence had made things worse in Helmand.