HE was supposed to just go quietly. Admit his personal failings. Beg tearful forgiveness for the sexual harassment of which he had been accused, and then disappear into shamed oblivion. Alex Salmond’s downfall last March had all the makings of a #Me Too show trial – Scotland’s answer to Harvey Weinstein. But it didn’t go quite to plan. Instead, the Scottish Government found itself in the dock last week – humiliated and shamed in the Court of Session.

The Government’s lawyers admitted the conduct of the quasi judicial procedure under which civil servants investigated Mr Salmond, and found him guilty, had been unlawful and unfair. This was a calamitous climbdown from which the Government may never fully recover, since it has exposed manifest incompetence and ignorance of the law among the highest reaches of the Government service.

If ever there was an investigation it simply had to get right, not least for the women who made the complaints, it was this investigation into the former first minister. The Government botched it.

It emerged in previously-withheld documents there had been contact between the investigating officer, Judith MacKinnon, and the “victims” before her inquiry was even convened. It appears from those documents, as outlined by Salmond’s counsel this week, that Ms MacKinnon had had to “encourage” the complainants to come forward, even though the main case had already been resolved by an earlier inquiry in 2013. This was an unconscionable violation of due process, made worse by the attempts by the Government to conceal it from the court.

It simply beggars belief these people are still in their jobs. It positively bankrupts belief that First Minister Nicola Sturgeon continues to defend them. How can any future victim of sexual harassment, or civil servant with a complaint, have any confidence in bringing their case forward, when these people are still in charge of handling it? There was even a suggestion they might reopen the inquiry into Salmond, which makes you wonder on what planet the Scottish Government has relocated itself.

Salmond is not fully vindicated, of course. That will only come if and when the police investigation into the sexual harassment allegations is dropped. It seems hard to believe that what emerged in court about the Government’s involvement with the complainants would not have a bearing on the prospects of a successful prosecution. But the former SNP leader is not out of the woods yet. However, the Scottish civil service, and Sturgeon, are now deep in the woods with him. And they are digging themselves further in by the day.

The parliamentary inquiry or inquiries that will surely follow this debacle, not least into the previously undisclosed contacts between Sturgeon and Salmond, will expose further aspects of this case. Then there is the question of damages, which Salmond has hinted at. This fiasco has already cost the Scottish taxpayer some £350,000. The bill will almost certainly be very much higher before the affair enters the history books.

The new complaints procedure was created at the height of the #MeToo panic in 2017, after Scottish lawyer Aamer Anwar claimed he had a “catalogue of abuse” about sexual harassment in Holyrood. These were never authenticated. In December that year, Permanent Secretary Leslie Evans set up a bespoke disciplinary procedure to target former Government ministers – not former civil servants, who appear to be exempt from the rigours of this retrospective quasi-judicial process. As if by magic, Salmond fell into the frame the moment the new procedure went live in January 2018. We now know how.

The Government tried to prevent the court seeing the documentation confirming all this, and when that failed, it collapsed the whole judicial review, by admitting it had behaved unlawfully. Sturgeon knew early on about the allegations against Salmond, not least because she had a series of private meetings with him last year, as revealed last week. In some of these meetings her chief of staff, Liz Lloyd, was also present. There are now questions about whether these meetings breached the ministerial code.

The First Minister’s defenders on social media claimed last week she had no control over the civil service and that this was all a “Yoon” plot to undermine the SNP, orchestrated by the UK Government. Nothing could be further from the truth. The senior civil servants and the Permanent Secretary, Ms Evans, are directly answerable to the First Minister, not the UK Government. She is the boss.

We can be confident Sturgeon was not responsible for leaking lurid details of the alleged assaults to the Daily Record in August, though she may have a pretty good idea who was. The Information Commissioner is now looking into the exposure of this material. This action was not only prejudicial to Salmond, but could have endangered the confidentiality of the alleged victims. Again, any parliamentary investigation will want to know names and pack drill.

But the leak is a sidebar to what is surely the worst scandal to hit Sturgeon since she became First Minister. It is the human dimension to this affair that makes it so serious. The women who made the complaints against Salmond must be near despair by now, as inquiry after inquiry bears down upon them.

Then there is the stress, expense and reputational damage inflicted on Salmond. The former first minister has been defamed on social media, with people routinely calling him a “sex pest” and much worse. Newspaper columnists said he was “finished” and brought down by his “unconquerable flaws”. He may have won his day in court, and may be in line for substantial damages, but nothing will assuage that assault on his character.

The civil servants probably thought his exposure was a slam dunk. Once the allegations of sexual harassment had been made public, new complaints would surely come flooding in. They didn’t. Instead, we have the dismal spectacle of a close-knit group of senior civil servants and political advisers closing ranks to protect their well-upholstered derrieres. Nicola Sturgeon, for reasons that remain inexplicable, has elected to act as their human shield.

Her loyalty may be admirable but it is entirely misplaced. The people she entrusted with conducting this inquiry were serially incompetent. The procedure itself, which she still maintains is “robust” is anything but.

Salmond was not allowed to see the reports that convicted him, nor was he able to question witnesses or the complainants. It was a kangaroo court, presided over by a Permanent Secretary who acted as judge and jury.

Personnel departments in many organisations are setting up their own pre-cooked inquisitions along similar lines. This whole area of instant law should be subject to wider judicial review. It was borne out of the understandable urge for zero tolerance of sexual harassment but, in the absence of due process, it has turned into zero justice.