SNP ministers chose to block the release of legal advice relating to the Alex Salmond affair despite two votes by Holyrood demanding its release, it has emerged.

The Government’s top law officer, the Lord Advocate James Wolffe QC, told MSPs he was only asked for his consent it to disclosure of the advice yesterday.

He said ministers hadn't decided that release would be in the "public interest" until that point.

The Scottish Tories said it was jaw-dropping that ministers "didn't lift a finger" to secure its publication. while the Liberal Democrats accused ministers of using their lawyers as "human shields".

The change of heart coincided with Deputy First Minister John Swinney being threatened with a no-confidence vote if he continues to withhold the material from parliament.

MSPs voted 63-54 on November 4 and 65-55 on November 25 to release the advice.

However appearing before the Holyrood inquiry into the Salmond affair, Mr Wolffe, the Government's most senior legal adviser, revealed ministers didn’t approach him about release for another three months.

The inquiry is looking at how the Government bungled a probe into sexual misconduct allegations made against Mr Salmond in 2018.

The former First Minister had the exercise set aside in a a judicial review in January 2019, showing it had been “tainted by apparent bias” and getting £512,000 in legal costs.

Mr Salmond argues the Government prolonged its defence of the case unreasonably, wasting public money and in breach of the ministerial code.

The inquiry has tried for months to see the legal advice to the Government which would show if this was true, but Mr Swinney repeatedly refused, despite Ms Sturgeon telling MSPs that the inquiry could get “whatever” documents it wanted.

Advice is now due to be released this afternoon.

READ MORE: John Swinney admits Government kept defending Alex Salmond case despite 'reservations'

Mr Swinney this morning admitted it would show there were “reservations” about what would prove a fatal flaw in the Government’s case in October 2018, however the Government only conceded the case in January 2019.

The Scottish Ministerial Code states that, although normally secret, legal advice to ministers can be disclosed in a two-part process.

It states: "If, in exceptional circumstances, Ministers feel that the balance of public interest lies in disclosing either the source or the contents of legal advice on a particular matter, the Law Officers must be consulted and their prior consent obtained.

"Such consent will only be granted where there are compelling reasons for disclosure in the particular circumstances."

In a letter to the inquiry on December 1, Mr Swinney appeared to suggest that the Lord Advocate had reservations about release of the advice.

He said: "As the Lord Advocate indicated in evidence to the Committee on 8 September and 17 November, there are very strong reasons of public policy for Government to be able to seek and receive confidential and candid legal advice, including in the context of litigation." 

However, asked by Tory MSP Murdo Fraser when Mr Swinney actually asked his permission to release the advice to the inquiry, the Lord Advocate said: "A submission was presented to the law officers yesterday."

Mr Fraser said: “So, when parliament voted for this back in November there was no approach made at that time?”

Mr Wolffe said: “The position is that ministers have formed a view that the first stage of the two-part process of the ministerial code is satisfied, that’s the public interest lies in favour of disclosure.

“At an earlier stage, ministers took the view that public interest did not favour disclosure.

“Ministers have now reached that view. The question of law officer consent, in the ministerial code, only comes into play at a point where ministers are satisfied that the first stage is met.”

Mr Fraser said: “I think we might deduce from that was that was changed ministers’ minds was the threat of a vote of no confidence, rather than any other factors.

Mr Wolffe said: “That’s clearly not a matter I’m going to comment on.”

Scottish Conservative leader Douglas Ross said: “This scandal grows deeper and deeper.

"Despite the Scottish Parliament backing two Scottish Conservative motions to release the legal advice, the SNP never even bothered to lift a finger to actually try and publish it.

“It's jaw-dropping that they didn't even ask if the Lord Advocate would allow it to be published. Instead, they let the public and press think he was the block on its release, when it was SNP ministers all along.

“We now know that John Swinney refused to even consider publishing the legal advice until his job was on the line.

“Our Vote of No Confidence remains on the table because it's clearer than ever that the government has ignored the will of the Scottish Parliament.”

Liberal Democrat MS Alex Cole-Hamilton added: "For weeks ministers tried to suggest that it was the law officers who were preventing this advice from being published. 

"I feel for the Scottish Government lawyers who have been used as human shields as a result of this deception.

"It's a shame that it has taken threats to John Swinney's ministerial career to open the door to these documents being handed to the committee.

"One thing that is clear is that if the SNP had a majority, they would have buried this legal advice for good and would use this committee as whitewash.”