British newspaper The Guardian on Friday lost its legal challenge against a decision banning the media from a court case about Prince Philip's will.
A High Court judge in September 2021 ruled the will should remain sealed for 90 years, to protect the privacy of his widow, Queen Elizabeth II, and other royals.
The hearing was held in private and media organisations were not allowed to attend.
The newspaper took legal action against the attorney general, who is the government's chief law officer, and the Queen's private lawyers, saying the media should have been allowed access.
Dismissing the newspaper's appeal, senior judges Geoffrey Vos and Victoria Sharp ruled that notifying the media about the hearing would have risked a publicity storm.
The hearing was at a hugely sensitive time for the sovereign and her family, and those interests would not have been protected if there had been protracted hearings reported in the press, the judges found.
Guardian lawyer Caoilfhionn Gallagher had argued that an entirely private hearing such as this is the most serious interference with open justice.
But the judges said the circumstances of the case were exceptional, and that UK probate rules allow wills and their values to be concealed from the public gaze in some cases.
It is true that the law applies equally to the royal family, but that does not mean that the law produces the same outcomes in all situations.
Unlike those of ordinary members of the public, wills of the Windsor family are traditionally kept secret after their deaths.
More than 30 members of the royal family have successfully applied at private court hearings to keep their wills secret since 1910, the newspaper said.
Prince Philip, who was also known as the Duke of Edinburgh, died in April last year, just weeks short of his 100th birthday, after more than a month in hospital.
He and the Queen were married for 73 years.
jwp/jit/ach