Scottish Ministers rejected a ruling by Scotland's Freedom of Information enforcer which compelled them to reveal whether it had taken legal advice to support its insistence that Scotland will continue in the European Union if it becomes independent.
Ministers referred the ruling to the Court of Session, claiming that the Scottish Information Commissioner had erred in law, but later abandoned the action and revealed that they had not taken any specific legal advice on Scotland in the EU.
Deputy First Minister Nicola Sturgeon has now revealed that the case cost nearly £20,000 in legal fees before it was abandoned.
Responding to written question by SNP MSP Clare Adamson, Ms Sturgeon said: "The total cost incurred by the Scottish Government was £19,452.92.
"This breaks down as Scottish Government's legal costs for Counsel of £3,960 including VAT, law accountant fees of £1,680 and Information Commissioner's fees of £13,812.92."
Following the revelation that legal advice did not exist, ministers commissioned its law officers to look into the issue.
Specific law officer advice on Scotland's potential future in the EU now exists, but the Scottish Government has declined requests to make the advice public.
Scottish Labour constitution spokesman Drew Smith said: "It's outrageous that the SNP has used public funds in an attempt to hide the truth ahead of the referendum.
"They're increasingly fond of using public funds for their own vanity projects, from trips to the golf, tartan trews and now to deceive on the constitution.
"Scotland isn't just on pause as it waits for next year's referendum, Scotland is now paying to hide the truth as the SNP's arguments continue to unravel."
The Scottish Government said the case was about a point of law which both the Commissioner and Scottish Government needed to clarify.
"By long-standing convention, successive Scottish and UK governments have not disclosed the fact or content of legal advice except in exceptional circumstances," a spokesman said.
A spokesman for External Affairs Minister Humza Yousaf said: "This is the height of hypocrisy from Labour and the Tories - both of whom made utterly false claims in Parliament that these costs were more than £100,000.
"When Labour and the Lib Dems were in office in Scotland they took five FOI cases to court in just two years, costing around £30,000, compared to just two cases in five years under this administration."