Q&A: Alex Salmond's legal victory
Alex Salmond has won his judicial review after the Scottish government conceded it had acted unlawfully while investigating harassment claims against him. What happened in court, and what does it mean going forward?
How did this come about?
Formal complaints about Mr Salmond's conduct were submitted to the Scottish government in January 2018, and were subsequently investigated internally.
The complaints, made by two female members of staff, date back to December 2013, when Mr Salmond was in office as first minister.
The former SNP leader described the claims as "patently ridiculous", denying all wrongdoing, and said the government's investigation had been "unfair and unjust".
He quit the party and brought legal action against the government, raising a judicial review of its complaints handling process at the Court of Session.
The government initially said it would "defend its position vigorously" in court.
The police launched an investigation of their own into the complaints, which remains entirely separate from the government's probe and the judicial review.
What happened in court?
The case was due to call for a four-day hearing in the Court of Session on 15 January, but an extra hearing was abruptly added this week.
At the hearing, it quickly became clear that this would be the end of the road, as Mr Salmond's team put forward a motion to conclude proceedings.
The two sides agreed a minute in which the Scottish government conceded that the investigation into Mr Salmond's conduct had strayed outside of the rules, and as such was unlawful.
Roddy Dunlop QC, speaking for the Scottish government, accepted that there had been a "failure" in following the complaints process, and that the reports resulting from the probe "could not be allowed to stand".
Mr Salmond called this an "abject surrender" by the government - which in turn contended that failures were restricted to a "single procedural flaw".
What exactly was the problem?
After the formal complaints about Mr Salmond were submitted to the Scottish government, an investigating officer was appointed to the case.
However, both sides now accept that the investigating officer had previously had contact with the complainers. The government's own rules state that there should not have been any prior involvement between the investigator and the complainers.
There was some disagreement between the two parties about the extent of this contact - Mr Salmond's team claim the officer's intervention bordered on "encouragement", while the government insist it was "welfare support and guidance" which was in itself appropriate.
However, the simple fact that contact took place was enough to knock down the process as a whole. This was the sole point the government conceded, but it was a fatal one.
What has all of this cost?
As part of the agreement struck between the two sides, the Scottish government will be paying some of Mr Salmond's costs - as well as their own.
Actions in Scotland's highest court do not come cheap. The former first minister claims the total cost to the taxpayer could rise to £500,000.
He also raised a six-figure sum through crowdfunding in advance of the hearing - and said afterwards that surplus funds from this would now go to "good causes".
So who is to blame?
The Scottish government has accepted "institutional responsibility" for the way the case has played out.
In court, Mr Dunlop was quick to underline that the investigating officer was a "dedicated HR professional" who had acted "in good faith", and stressed that there was "no question of an individual being held up as a sacrifice".
Mr Salmond has singled out the Scottish government's most senior civil servant, permanent secretary Leslie Evans, as being responsible for what he called an "abject humiliation". Outside the court, he repeatedly called on her to consider her position.
The government responded that Ms Sturgeon still has "full confidence" in Ms Evans, and said she had not offered her resignation. The same applies to the investigating officer in the case.
It is not entirely clear at what point the government became aware of the crucial point which swung the case, having previously insisted that it would contest the case "vigorously".
Ms Evans said "the full picture only became evident in December 2018", while papers were being compiled for the planned court action.
Does this have any impact on the police investigation?
No. The police probe into the complaints is entirely separate to the government one, and it continues.
Officers have spoken to government staff as well as employees at Edinburgh Airport as part of their inquiry.
Mr Salmond denies "all suggestions of misconduct at any time". On Tuesday, he declined to comment on the police investigation until it has concluded.
What does this mean for the complainers?
Ms Evans spoke to both women in recent days, and the government has said it will continue to offer them support.
Neither complaint has been withdrawn, meaning the government still has the option of pursuing a fresh investigation.
Ms Sturgeon, Mr Dunlop and Ms Evans all sought to stress that the judicial review had no bearing either way on the merit or credibility of the complaints themselves, but was purely about the process of the investigation.
Because of this, Ms Sturgeon said it was "open to the Scottish government to re-investigate these complaints".
However, she said this would be considered "only when the ongoing police investigation has concluded".
What has Nicola Sturgeon's involvement been?
Ms Sturgeon had no formal role in the complaint process while it was ongoing, but became aware of the case after Mr Salmond told her about it at her home in Glasgow in April 2018.
She told MSPs she had spoken to her predecessor about the case on five occasions - including three meetings in person.
However, she said she "was always clear that I had no role in the process", adding that she "did not seek to intervene in it at any stage nor indeed did I feel under any pressure to do so".
She added that she had not spoken to Mr Salmond since 18 July 2018.
The Conservatives and Labour both pressed Ms Sturgeon about her meetings with Mr Salmond, but she said she was "absolutely satisfied" that she had acted appropriately.
And she had repeatedly insisted that the government was right to investigate the complaints, and that they should not be "swept under the rug".
Will the government be changing its processes?
It appears not. The government is standing behind the complaints handling process, which was signed off by Ms Sturgeon in December 2017.
Both Ms Sturgeon and Ms Evans have insisted that the process remains "completely robust", despite the "deeply regrettable" failure in the investigation of Mr Salmond.
An internal review of "the specific application of this one element of the procedure" has been ordered.
Mr Salmond described the process as a "botched mess", but his successor said it was important that anyone who might come forward with a complaint about any minister of former minister in future could be confident that the process was "robust in every respect".
She said her government was "determined to learn and apply lessons from this case so that any member of staff raising complaints in future can have confidence that every aspect of the process applied will be robustly".