The Scottish government has been threatened with legal action after it missed a deadline to release files from an inquiry into whether Nicola Sturgeon broke the ministerial code.
The former first minister was cleared of breaching the ethics code by an independent advisor in 2021, following the botched investigation into her late predecessor Alex Salmond.
But the Scottish Information Commissioner has now confirmed he will refer the matter to the Court of Session if written evidence he requested - on Sturgeon's handling of the harassment claims - is not released by 22 January.
A Scottish government spokesperson said it would "comply" with David Hamilton's decision but was working to avoid identifying people involved.
Last November Hamilton ruled that the government wrongly withheld information relating to the ongoing investigation.
And he said it had to hand over some of the written evidence used in the probe by 15 January.
But just minutes before the deadline passed he was informed the material would not be released.
Hamilton said the "practice of last-minute communication" by the Scottish government on cases relating to the Hamilton Inquiry "reflects poorly on the ministers and disrespects the applicant and wider Scottish public on a matter of significant public interest".
The commissioner also warned he would "not hesitate to refer the matter to the Court of Session" if ministers failed to comply by Thursday - a week on from the original deadline.
"The Court may investigate the matter and treat the failure to comply as contempt of court," Hamilton added.
The government said it had written to the commissioner to inform him that they would not meet the 15 January deadline.
A spokesperson added: "The Scottish government will comply with the commissioner's decision, but we are also required to give consideration to the need to avoid inadvertent jigsaw identification in order to comply with court orders.
"We are working to complete this work as soon as possible."
The issue dates back to March 2021, when independent adviser James Hamilton KC - no relation - cleared the then first minister of breaching the ministerial code.
A freedom of information (FOI) request was then made to the Scottish government for all written evidence used in the investigation.
The government had originally insisted that as Hamilton was an independent adviser on the ministerial code he was not subject to freedom of information legislation.
However, the Information Commissioner intervened and ordered the government to look at the case again.
Ministers then challenged this decision in the Court of Session but their appeal was refused.
After a lengthy series of complex appeals, the Information Commissioner ordered ministers to release some of the evidence by Thursday but that didn't happen.
In August Alex Salmond's niece said the family was determined to "defend his name" in legal action against the Scottish government.
Christina Hendry also claimed there had been a conspiracy against Salmond - the former first minister and SNP leader who was cleared at trial of 13 sexual offences in 2020.
When he died aged 69 last year, Salmond had been suing the Scottish government over a botched investigation into harassment complaints made about him.
His widow Moira has since taken up the case - although Salmond's estate is now being wound up by bankruptcy accountants, after it transpired he died with debts of more than £340,000 stemming largely from legal fees.