You would assume that civil servants faced with allegations of sexual assault by a former first minister of Scotland would proceed with the utmost caution; that they would fireproof themselves against a future appeal by making sure the procedure used to investigate those allegations was robust and that it was followed to the letter. With the #MeToo campaign in the headlines and a report suggesting that, despite its conceit of itself as family-friendly, Holyrood has the same level of sexual harassment as Westminster, the stakes surrounding the inquiry into Alex Salmond’s alleged behaviour towards two female members of staff in 2013 could scarcely have been higher.

Knowing the former SNP leader would pore over every detail, as he had every right to do, they owed it to the women involved to ensure their handling of the complaints was beyond reproach. Instead, it emerged at Salmond’s judicial review, one aspect of the process was so flawed as to invalidate the entire investigation.

At the court of session in Edinburgh on Tuesday, the Scottish government accepted that civil servant Judith MacKinnon had had “prior contact” with the complainants before she was appointed to lead the inquiry. It was also suggested she was involved in drafting the new procedures which allowed the complaints to be brought. Salmond’s lawyers claimed her advice was tantamount to encouraging the women to take action; Scotland’s top civil servant, Leslie Evans, and the Scottish government deny this. Either way, Lord Pentland ruled – and the Scottish government conceded – that the lapse created an impression of bias, and that the inquiry was therefore unlawful. As a result it agreed not to publish its report.

It is impossible to overstate how disastrous this fundamental error is proving: for Evans, for the Scottish government, for the SNP, for the women themselves and for the taxpayer left to foot the six-figure legal bill. While far from welcome, the high-profile allegations (which Salmond has always denied) gave the Scottish government an opportunity to demonstrate its commitment to tackling such allegations regardless of the allegiances of the accused. Indeed, Nicola Sturgeon was much lauded for putting personal loyalties aside and insisting the complaints must be pursued without fear or favour. Now, instead of enhancing its credibility, the civil service and, by association, the Scottish government, appear at best incompetent and at worst complicit.

There is no evidence that Salmond was deliberately targeted, as some who took to Twitter claimed. Still, if those involved at the highest level did not understand the importance of appointing someone completely unconnected to the complainants to head the inquiry – a basic of HR procedures – how can we have faith in anything they do?

Sturgeon defends handling of Salmond sexual harassment case Read more

Though Sturgeon was not privy to the investigation, she still has questions to answer. She has never properly explained her three private meetings with Salmond after the allegations were made. The first minister has also thrown her weight behind Evans. In a statement on Tuesday, she said she had full confidence in the permanent secretary and that she would remain in her post. But Evans didn’t helped herself by issuing a statement in which she claimed that all Salmond’s other complaints about the process – including that he had been denied access to the evidence – had been “dismissed” (they were dismissed only in the sense they were not considered because they had become “academic”).

With calls for a scalp coming from all sides, Evans may yet be forced out, especially if the police investigation ends with no charges. And, if she is, Sturgeon’s credibility will be further undermined. But the greatest casualty of this debacle is trust in the process.

That the Scottish government’s investigation was ruled unlawful has no bearing on the credibility of the allegations. The police inquiry is ongoing and will examine them on their own merits. Equally, there is nothing to stop the Scottish government ordering another internal inquiry once Police Scotland has concluded its own. But the judicial review has allowed Salmond to take centre stage; the impression given – wittingly or unwittingly – is that he is a victim, unfairly hounded. Once again, the women are having to see themselves portrayed online as politically motivated liars when the outcome of the judicial review makes no such judgment.

This is the most devastating potential repercussion: that the already fragile trust in the complaints system will be further eroded and that this will dissuade women from coming forward. Such an erosion of confidence is the opposite of what the #MeToo campaign was supposed to achieve – and the opposite of what the Scottish government intended when it ordered a review of the procedure. On Tuesday, Sturgeon said the Scottish government would offer the women any support they require, as it should. But who now would blame the women for telling them where to stick it?

• Dani Garavelli is a freelance journalist and columnist for Scotland on Sunday