Alex Salmond has won his legal battle with the Scottish Government after it admitted it mishandled sexual harassment complaints against him.

Mr Salmond, 64, was accused in January 2018 of sexual misconduct by two female civil servants relating to his time in office five years earlier.

He has always strongly denied the allegations and any criminality. A separate police investigation is ongoing.

The former First Minister launched a judicial review into the way the Scottish Government handled the case.

The Government has now admitted it breached its own guidelines by appointing an investigating officer who had "prior involvement".

Speaking after a hearing at the Court of Session in Edinburgh, Mr Salmond hailed an "emphatic victory".

He accused the Scottish Government's Permanent Secretary Leslie Evans of wasting "huge amounts of public money in an incompentent attempt to enforce an unlawful process". 

He added: "Now, having incurred those costs to the public purse, she has collapsed the case prior to a full hearing."

He said the Scottish Government's "conduct in this case as an institution has unquestionably lacked candour" and accused it of repeatedly failing to disclose crucial documents.

"As a former First Minister, I find that conduct entirely unworthy," he added, before also attacking leaks to the media.

The Herald:

(Photo: Gordon Terris/The Herald)

In a lengthy statement, Ms Evans apologised for how the complaints were dealt with.

However, she also left the door open for the Scottish Government to re-investigate the allegations.

She said: "Lawyers for the Scottish Government and for Alex Salmond have this morning informed the Court of Session that his action has been settled and the Court has approved that settlement.

"As part of the settlement, I have accepted that the decision reached after the investigation of two complaints made against Mr Salmond should be set aside.

Read more: Staff contacted as part of ‘Operation Diem’ police probe into Salmond sexual misconduct claims

"This action is being taken because it has become clear that, in one respect only (albeit an important one), the investigation was procedurally flawed.

"However, it is important to stress that this relates to the operational application of the Procedure for Handling Complaints Involving Current or Former Ministers (‘the Procedure’).

"The Scottish Government considers the Procedure itself to be robust and it remains in place.

"After reassessing all the materials available, I have concluded that an impression of partiality could have been created based on one specific point - contact between the Investigating Officer and the two complainants around the time of their complaints being made in January 2018.

The Herald:

(Photo: Gordon Terris/The Herald)

"The full picture only became evident in December 2018 as a result of the work being undertaken to produce relevant documents in advance of the hearing.

"I want to apologise to all involved for the failure in the proper application of this one particular part of the Procedure.

"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.

"All the other grounds of Mr Salmond’s challenge have been dismissed.

"The Scottish Government has acted in good faith at all times and will continue to do so. It was right and proper that these complaints were investigated and I stand by the decision to carry out that investigation.

"It is also important to note 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.

"The Judicial Review was never about the substance of the complaints, but about the process that took place to investigate those complaints.

Read more: Alex Salmond resigns from SNP

"It is accordingly open to the Scottish Government to re-investigate the complaints and, subject to the views of the complainants, it would be our intention to consider this - however, this will only be once ongoing police inquiries have concluded.

"Meantime I have commissioned an internal review of the specific application of this one element of the procedure.

"We shall learn and apply the lessons of this case to any future complaint addressed under our internal procedure.

"My priority remains the duty of care to my staff, including anyone in the organisation who brings forward any concerns about inappropriate conduct, regardless of the identity or seniority of the individual complained about.

"Finally I would reiterate that the single procedural flaw which led to this decision is deeply regrettable. In particular, I regret the distress it will cause to the two women who raised the complaints."

After Mr Salmond's legal action was launched last year, the Scottish Government repeatedly said it would “vigorously defend” how it investigated the complaints against him.