Ministers have spent more than £250,000 in legal fees to prevent the publication of letters written by Prince Charles to politicians.

The attorney general, Dominic Grieve, with the backing of the cabinet, has been blocking the release of the letters as he says their contents threaten to damage the prince's political neutrality and create constitutional problems.

This month, three senior judges ruled Grieve had acted unlawfully when he overrode an independent tribunal by vetoing the disclosure of the letters, which would show how the prince sought to influence the government's decision-making.

The ruling in the court of appeal was won by the Guardian, which for nine years has been pressing to see the letters.

Following a parliamentary question by Labour MP Paul Flynn, Grieve has disclosed that eight government departments have spent £274,481.16 on barristers and other lawyers over the past four years.

He said the "case raises issues of constitutional significance, including upholding parliament's intentions for the freedom of information regime and the government's ability to protect information in the public interest".

Flynn said: "This denial of information by government is a sinful waste of public money. If there is something in the letters that suggests Prince Charles will be a poor monarch, then his future subjects have a right to know.

"The head of state is a position of great influence and a clash between an opinionated head of state and a government could cause a constitutional crisis."

Over the past four years, the government has hired lawyers to contest a series of hearings into whether the letters – said by Grieve to contain the prince's "most deeply held personal views and beliefs" – should be released to the public under the Freedom of Information Act.

Two years ago, the independent freedom of information tribunal ruled against the government and ordered that the letters should be published as the public should know how the prince had sought to influence ministers in the last Labour government.

A month later, Grieve overruled the tribunal and vetoed the publication of the letters, which he said were "particularly frank".

Grieve justified his use of the veto by arguing that the public could read the letters and believe that the heir to the throne had been "disagreeing with government policy".

This perception, he added, "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".

The veto was challenged by the Guardian in the courts. The government lost again this month when the master of the rolls, Lord Dyson, and two other judges decided that Grieve had acted unreasonably when he overrode the freedom of information tribunal. Dyson also ordered the attorney general to pay the Guardian's legal costs, totalling £96,000.

As the case stands, the government will have to publish the letters unless it can win an appeal at the supreme court.

Grieve said in the parliamentary answer: "If we are successful in the next stage of legal proceedings, the government would seek to recover a substantial proportion of these costs from the Guardian."

The government is understood to have engaged new lawyers to fight its corner at the supreme court.

The prince has for years been sending letters – known as the "black spider" memos because of his handwriting – to politicians, outlining his views on public issues.

The Guardian has been seeking to see 27 pieces of correspondence between the prince and ministers in seven government departments between September 2004 and April 2005.

The letters were sent to ministers in the Cabinet Office and the departments responsible for business, health, schools, environment, culture and Northern Ireland.