The Scottish government has admitted acting unlawfully while investigating sexual harassment claims against Alex Salmond.
Allegations against the former first minister, which he denies, were made to the Scottish government a year ago.
The government has now admitted it breached its own guidelines by appointing an investigating officer who had “prior involvement” in the case.
As a result, it conceded defeat in its legal fight with Mr Salmond.
Mr Salmond’s case focused entirely on the fairness of the government’s procedures and will have no bearing on a separate police inquiry into the allegations, which is still ongoing.
‘Sad it was necessary’
Speaking outside the Court of Session in Edinburgh, Mr Salmond said the case had resulted in “abject humiliation” for the Scottish government, which he led from 2007 until 2014.
He added: “The last time I was in that court was to be sworn in as first minister of Scotland. I never thought it possible that at any point I would be taking the Scottish government to court.
“Therefore while I am glad about the victory which has been achieved today, I am sad that it was necessary to take this action.”
He also repeated his calls for the Scottish government’s most senior civil servant, Leslie Evans, to consider her position, and warned that the case could cost the public purse £500,000.
And he thanked the 4,000 people who contributed more than £100,000 to a crowdfunding appeal to help pay for his legal challenge to the government’s handling of the case.
With the government agreeing to pay his legal costs, he said the money will go to good causes in Scotland and elsewhere.
The government’s admission that it had not followed the correct procedures came during a hearing at the Court of Session on Tuesday morning.
Judge Lord Pentland subsequently said that the government’s actions had been “unlawful in respect that they were procedurally unfair” and had been “tainted with apparent bias”.
The Scottish government’s admission centred on an official it appointed to investigate the complaints against Mr Salmond, which were made by two women.
Its lawyer, Roddy Dunlop QC, told the court that the investigating officer was a “dedicated HR professional” who acted in good faith, but did have some contact with the complainers before being appointed to the case.
Mr Dunlop said this had led the government to accept there had been a “failure” in one aspect of the investigation, which could have given the impression that they were not acting impartially.
But he said the government did not accept a claim by Mr Salmond’s legal team that the investigating officer had effectively been “assisting the complainers” and “giving them encouragement”.
He also said there was “no question of an individual being held up as a sacrifice”, and that the government had a “duty to investigate the serious complaints” that had been made.
In a statement released after the case was resolved, Ms Evans – the Scottish government’s permanent secretary – said she wanted to “apologise to all involved for the failure in the proper application of this one particular part of the procedure”, and in particular the two complainers.
But she insisted: “There is nothing to suggest that the investigating officer did not conduct their duties in an impartial way.
“Unfortunately, the interactions with the complainants in advance of the complaints being made meant that the process was flawed, however impartially and fairly the investigating officer conducted the investigation.”
Ms Evans stressed that it was “right and proper that these complaints were investigated”, and that the “procedural flaw in the investigation does not have implications, one way or the other, for the substance of the complaints or the credibility of the complainers”.
And she said it was open to the Scottish government to re-investigate the complaints, adding that “subject to the views of the complainants, it would be our intention to consider this”.
But Ms Evans said this would “only be once ongoing police inquiries have concluded”.
A spokesman for First Minister Nicola Sturgeon said she continues to have full confidence in Ms Evans, and the civil servant has not offered her resignation.
Ms Sturgeon previously said the complaints against Mr Salmond were too serious to ignore, and could not be “swept under the carpet”.
And she had previously defended the Scottish government’s procedures, saying it would “defend its position vigorously” in court.
A four-day hearing on the case had been due to begin at the Court of Session in Edinburgh next week, but that will now not go ahead.
The allegations against Mr Salmond date back to 2013, when he was still first minister. He has described the claims as “patently ridiculous”.
The former MSP and MP, who lost his Westminster seat in the 2017 general election, resigned from the SNP in August but said on Tuesday he wants to rejoin.