High Court judges have ordered a fresh inquest into the death of soldier Pte Cheryl James who died at Deepcut barracks.
Her family applied for a fresh investigation with the consent of the Attorney General.
Pte James, 18, was found dead from a single gunshot wound in November 1995. An inquest recorded an open verdict.
She was one of four soldiers who died at the Surrey barracks between 1995 and 2002 amid claims of bullying and abuse.
Privates Sean Benton, James Collinson and Geoff Gray also died from gunshot wounds.
Mr Justice Mitting and Judge Peter Thornton QC both agreed that there was "an insufficiency of inquiry" at the 1995 inquest and quashed its open verdict.
Judge Thornton said "the discovery of new facts or evidence" made "a fresh investigation including a fresh inquest necessary or desirable in the interests of justice".
Pte James was undergoing initial training at Deepcut when she was found dead with a bullet wound between her right eye and the bridge of her nose.
Her parents, Des and Doreen James, applied through human rights campaign group Liberty for a new inquest after the Human Rights Act was used to secure access to documents held by the authorities about the teenager's death.
Mr and Mrs James said they were "delighted" to have a fresh inquest but " a meaningful inquiry into Cheryl's death is almost 20 years late".
They said in a statement: "When young people die in violent circumstances, a rigorous and transparent investigation should be automatic.
"Something went dreadfully wrong at Deepcut yet until now no-one has bothered to look at how and why our daughter died.
"We can only hope that Cheryl's legacy helps change the current ineffective and discredited military justice system."
Liberty solicitor Emma Norton, who represented them, said: " Cheryl's family refused to let her death be swept under the carpet but they've had to fight at every stage for answers in the face of a state that thought it could ignore the basic human rights of its troops.
"Cheryl was preparing for a life of service and deserved so much better - her family can now hope to finally get some answers."
The new investigation is to be carried out by the current senior coroner for the Surrey area, who did not conduct the original inquest, or by a coroner to be agreed by the senior coroner, the Chief Coroner and Judge Thornton.
Judge Thornton said the inquest could be held outside Surrey if the senior coroner considers "in view of any aspect of the Surrey Police's prior involvement in this case" that it would be "inappropriate" for the inquest to be held in his area.
Explaining why a fresh inquest was necessary, Judge Thornton said Pte James was a recruit with the Royal Logistical Corps (RLC) when she died at Princess Royal Barracks.
She had been posted, alone, dressed in battledress and armed with an SA80 rifle to a gate known as A2 at Royal Way on November 27 1995.
She was found at about 8.30am close to the gate in a small wooded area surrounded by trees with a single bullet wound to the front of her head and no other signs of injury.
On the day of her death she was reported to be in good spirits, and in the preceding weeks had been described as "cheerful, happy and content".
She was "fit and healthy and enjoyed life in the Army".
The first inquest was completed on December 21, less than a month after she died. An early assumption had been that she had taken her own life.
Almost from the start of the investigation Surrey Police handed it over to the Royal Military Police Special Investigations Branch (SIB).
Judge Thornton said the original investigation was "extremely limited and had flaws".
The fragmented bullet from the death was not examined and was later lost. Also lost were the bullet's casing and other bullets in the rifle, and Pte James's clothing.
"Her rifle was not examined forensically. No fingerprints were taken from it. No gunshot residue tests were made."
Only a limited number of witness statements were taken. Very few witnesses were called to give evidence, and it was not surprising that the scope of the inquest was "circumscribed", said the judge.
The then Surrey coroner concluded with an open verdict after saying he was not able to find that suicide was proved beyond reasonable doubt.
Judge Thornton said Surrey Police reopened their investigation into Cheryl's death in July 2002 following further deaths at Deepcut and allegations there had been an "inadequate inquiry" into them.
The reinvestigation was itself the subject of a review by Devon and Cornwall Police in August 2005 called "Operation Stanza".
In November 2004 the minister of state for the Armed Forces announced his decision to commission an independent review into four deaths at Deepcut, including Cheryl's.
Nicholas Blake QC, now a High Court judge, carried out the review and published his report in March 2006.
But he made it clear his review was "not a substitute for an inquest" and suggested if the James family wanted a fresh inquest he believed it would be appropriate.
He also recommended that the family was entitled to full disclosure of the Surrey Police reinvestigation report.
Judge Thornton said the police at first refused disclosure, but handed over some 44 lever arch files of documents after being threatened with legal action.
The police said there was further relevant material which had still not been provided to the family - but what had been disclosed "affords fresh grounds for an inquest".
This included "important material relating to ballistics, the noise of the gunshot, bullet fragments, the finding of the body, the credibility of some witnesses, and further witnesses."
The judge declared: "I have come to the conclusion on the material put before us that, by reason of insufficiency of inquiry and the discovery of new facts or evidence, it is necessary or desirable in the interests of justice that a fresh investigation including a fresh inquest should be held."
The family's application for a fresh inquest was not opposed by the Surrey Coroner or the Ministry of Defence.