LONDON -- A British judge ruled Wednesday that the Duchess of Sussex can keep the names of five close friends secret while she brings a privacy invasion lawsuit against a British newspaper -- but he chided both sides in the case for playing out their battle in the media as well as the courtroom.

High Court judge Mark Warby agreed, "for the time being at least," to grant Meghan's request to protect the anonymity of friends who defended her in the pages of a U.S. magazine in order to spare them a "frenzy of publicity" before the case comes to a full trial.

The former Meghan Markle is suing the publisher of the Mail on Sunday and the MailOnline website over five articles that published portions of a handwritten letter she wrote to her estranged father, Thomas Markle, after her marriage to Prince Harry in 2018.

Meghan, 39, is seeking damages from publisher Associated Newspapers Ltd. for alleged misuse of private information, copyright infringement and data protection breaches.

The duchess asked the judge to prohibit publishing details of female friends who spoke anonymously to People magazine to condemn the alleged bullying she had received from the media. She argued that the friends were not parties to the case and had a "basic right to privacy."

The women's names are included in a confidential court document, but they have been identified in public only as A to E.

Associated Newspapers' attorney Antony White said during a court hearing last week that the friends were potential witnesses, and keeping their names secret "would be a heavy curtailment of the media's and the defendant's entitlement to report this case, and the public's right to know about it."

The judge acknowledged he had to balance "the competing demands of confidentiality and open justice."

Warby ruled in favour of anonymity, saying it would serve justice by shielding Meghan's friends from the "glare of publicity."

"Generally, it does not help the interests of justice if those involved in litigation are subjected to, or surrounded by, a frenzy of publicity," he said.

But he added that when it comes to a full trial, "that is a price that may have to be paid in the interests of transparency."

No date has been set for the full trial, which is expected to start next year and will likely be one of the United Kingdom's highest-profile civil cases in some time.

The judge said that during the pretrial wrangling, each side had "overstated its case" and made "hyperbolic assertions" about the other.

"Both sides have demonstrated an eagerness to play out the merits of their dispute in public, outside the courtroom, primarily in media reports," Warby said. "That approach to litigation has little to do with enabling public scrutiny of the legal process, or enhancing the due administration of justice."

Associated Newspapers, which is contesting the duchess's privacy-infringement claim, says it was Meghan's friends who brought the letter into the public domain by describing it in the People article. One told the magazine that the duchess had written: "Dad, I'm so heartbroken. I love you. I have one father. Please stop victimizing me through the media so we can repair our relationship."

The publisher's lawyers argue that the information about the letter must have come "directly or indirectly" from Meghan.

They say Thomas Markle then revealed the letter to the Mail to correct the false impression Meghan's friends had given about him to People.

Meghan's attorneys say the duchess was unaware her friends were speaking to the magazine. They say the anonymous interviews were arranged by one of the five friends, who was concerned about the toll media criticism was taking on the duchess, pregnant at the time with her first child.

Mark Stephens, a media lawyer at London legal firm Howard Kennedy, said Wednesday's ruling was important because the case hinged on "whether or not Meghan, through her friends, curated an attack on Thomas Markle."

"If they did, he was entitled to respond by giving the letter or extracts of the letter to the Mail on Sunday," Stephens said.

American actress Meghan Markle, star of TV legal drama "Suits," married Harry, grandson of Queen Elizabeth II, in a lavish ceremony at Windsor Castle in May 2018. Their son, Archie, was born the following year.

In January, the couple announced they were quitting royal duties and moving to North America, citing what they said was unbearable intrusion and racist attitudes from the British media. They are currently based in the Los Angeles area.

------

Associated Press Writer Danica Kirka contributed to this story