A judge has thrown out the findings of a Scottish government investigation into Alex Salmond.
It was over allegations of sexual misconduct against the former First Minister, which he denies.
Two women lodged complaints against Mr Salmond last year concerning alleged events in 2013.
The Scottish Government accepted in court that there had been a failure in procedure and that an internal review would be carried out.
The former SNP leader called for Scotland's top civil servant, Permanent Secretary Leslie Evans, to quit her post.
Mr Salmond said he was "glad to have won" the case "and sad that it was necessary to take this action".
He added: "The government has made an abject surrender in terms of the case before we even got to the first day of hearings.
"Back in August when I made my last comments on these matters, I said that the process that was used against me was unfair, unlawful and tainted by bias.
"I also said I was not guilty of any criminality.
"The first of these has been established. The second is to come.
"But a former first minister of Scotland requiring to take the administration of the Scottish government to court to establish that point should not have been necessary.
"I think the person responsible should be considering her position."
Lawyers for Mr Salmond argued that the Scottish government had acted unlawfully in its handling of complaints against him.
They stated that the process was unfair and tainted by apparent bias.
While civil service guidelines dictated there should be no contact between the people making complaints and those investigating them, Mr Salmond's lawyers said this was not the case.
In fact, they said, the civil servant who was investigating did indeed have prior contact with the complainants.
Mr Salmond's lawyers said she gave them a significant degree of assistance in making formal complaints against the politician - and claimed this bordered on encouragement.
Ms Evans said the procedural flaw in the Scottish government's investigation was "deeply regrettable" and did not have implications "for the substance of the complaints or the credibility of the complainers".
She said the government would consider reinvestigating the complaints "once ongoing police inquiries have concluded".