(Reuters) - Britain's Supreme Court ruled on Thursday that 27 letters written by Prince Charles to ministers in 2004-2005 can be disclosed to the media, a step that could cast doubt over the political neutrality of the future king.

The Guardian newspaper has sought for a decade to obtain the letters sent to ministers in then-Prime Minister Tony Blair's government. But despite winning a court victory, disclosure was blocked by former Attorney General Dominic Grieve in 2012.

After the Court of Appeal ruled last year that his ministerial veto was unlawful, Grieve appealed to the Supreme Court in a last-ditch attempt to stop disclosure, arguing it could undermine Prince Charles' position.

"We dismiss the Attorney General's appeal," the court's President David Neuberger said in his ruling.

The Supreme Court does not have the letters and they will not be immediately released. Government departments are in possession of the letters and it was not immediately clear how disclosure would be handled following the Supreme Court ruling.

"This is a matter for the government," said a spokeswoman for Prince Charles at Clarence House, his official London residence. "Clarence House is disappointed the principle of privacy has not been upheld."

There was no immediate comment from the Attorney General's office.

Under Britain's unwritten constitution, the royal family should remain politically neutral. Queen Elizabeth has steadfastly kept her opinions to herself during her 63-year reign.

Charles, in contrast, has expressed views about subjects close to his heart such as nature conservation, architecture and genetically modified crops.

His letters to ministers, nicknamed "black spider memos" because of his scrawled handwriting, are potentially controversial if they create the perception that he disagreed with the government and attempted to influence policies.

Grieve had argued that such a 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."