Judges have ruled that the public has no right to read documents that would reveal how Prince Charles has sought to alter government policies.

Three high court judges have have rejected a legal attempt by the Guardian to force the publication of private letters written by the prince to government ministers.

Cabinet ministers conceded that the prince's private letters – dubbed "black spider memos" because of their scratchy handwriting – contained Charles' "most deeply held personal views and beliefs", which could undermine the perception of his political neutrality.

In a verdict published on Tuesday, the lord chief justice of England and Wales, Lord Judge, ruled that the attorney general, Dominic Grieve, had acted properly when he employed a rarely used veto to block publication of the letters.

The lord chief justice, however, noted that the existence of the veto was troublesome and appeared to be "a constitutional aberration".

The Guardian is intending to appeal. A spokeswoman for the newspaper said: "We are obviously disappointed. We consider the publication of these letters to be squarely in the public interest."

Tuesday's ruling follows an eight-year battle by the newspaper to shed more light on the way the heir to the throne seeks to influence government ministers, even though he holds no elected position.

Grieve had argued that disclosure of the 27 "particularly frank" letters between the prince and ministers over a seven-month period would have seriously damaged his future role as king. The attorney general said there was a risk that the prince would not be seen to be politically neutral by the public if the letters were published.

"This risk will arise if, through these letters, the Prince of Wales was viewed by others as disagreeing with government policy. Any such perception would be seriously damaging to his role as future monarch because if he forfeits his position of political neutrality as heir to the throne he cannot easily recover it when he is king," Grieve had said.

In 2005 the Guardian submitted a request under the Freedom of Information Act (FoI) to see copies of correspondence between the prince and ministers in seven government departments, but the government refused to grant the request.

The paper won a landmark victory last September when three judges in an FoI tribunal ordered the government to publish the letters, saying it was "in the public interest for there to be transparency as to how and when Prince Charles seeks to influence government".

However, a month later, Grieve, with the support of the cabinet, issued the veto that overrode the tribunal's decision.

The Guardian went to the high court to argue that the cabinet had acted unlawfully by deploying the veto to block the disclosure of the letters. It was the first challenge of its kind to try to obtain royal correspondence.

On Tuesday, the lord chief justice, accompanied by Lord Justice Davis and Mr Justice Globe, dismissed the challenge, finding that Grieve had acted in the public interest in a "proper and rational way".

However, Judge said that the power of ministers under the FoI Act to issue a veto and override a decision reached by judges raised "troublesome concerns", particularly since even a ruling by the supreme court could be overridden.

He said: "The possibility that a minister of the crown may lawfully override the decision of a superior court of record involves what appears to be a constitutional aberration. "

In a written statement he said: "It is an understatement to describe the situation as unusual."

He added that barristers could find no equivalent in any other British law. "It is not quite a pernicious 'Henry VIII' clause, which enables a minister to override statute, but, unconstrained, it would have the same damaging effect on the rule of law."

However, Judge said the possibility that any override could be challenged in a court "provides the necessary safeguard for the constitutionality of the process".

Tuesday's ruling follows long-running concerns that the prince has been meddling in official policies for many years.

Ministers, fearing that the prince's letters could be disclosed under the FoI Act, tightened up the law in 2011 to block any chance of their being published.

Ministers say Charles' letters must be concealed as this lets him air his views privately with ministers so he can "be instructed in the business of government".