LONDON — Britain's Supreme Court Thursday paved the way for the public release of 27 hotly contested memos written by Prince Charles to government ministers.

The government has sought for years to keep the letters out of the public domain for fear that publishing them might damage public perceptions of Charles' neutrality.

As heir-to-the-throne, Charles is expected to remain out of politics. The letters, said to contain strong personal views, were deemed too sensitive by former Attorney General Dominic Grieve, who vetoed their release in 2012.

An Appeals Court overruled him last year, and now the Supreme Court has upheld that decision.

Conceding defeat, Prime Minister David Cameron said the government will begin preparatory work toward releasing the papers.

"This is a disappointing judgment and we will now consider how to release these letters," he said. "This is about the principle that senior members of the Royal Family are able to express their views to government confidentially. I think most people would agree this is fair enough."

Charles, known to have strong views on architecture, genetically modified crops, climate change and other matters, also said through a spokesman that he was disappointed that the principle of privacy had not been upheld.

The court's decision marks the success of a lengthy legal Freedom of Information battle by the Guardian newspaper to obtain the so-called "black spider" memos, which are named after his distinctive handwriting.

The Guardian's chief editor, Alan Rusbridger, said editors are "delighted" with the decision.

"The government wasted hundreds of thousands of pounds trying to cover up these letters, admitting their publication would 'seriously damage' perceptions of the prince's political neutrality," he said. "Now they must publish them so that the public can make their own judgment."

The timetable for the release of the letters is not yet clear. It is also not known if the government will seek to redact certain portions of the letters.