The Scottish government has come under pressure after it conceded defeat in Alex Salmond's judicial review of how harassment allegations against him were investigated. How has the probe played out over the last year?
October 31, 2017 - Ministers order a review of the Scottish government's "policies and processes for addressing inappropriate conduct" in the wake of sexual harassment scandals in politics and showbiz. This is led by the government's top civil servant, Permanent Secretary Leslie Evans.
December - First Minister Nicola Sturgeon signs off the government's new process for dealing with complaints of sexual harassment and misconduct.
January 2018 - Two female staff members make formal complaints to the Scottish government about Alex Salmond's conduct, dating back to when he was first minister in December 2013. An internal inquiry is established and an investigating officer appointed.
March - Mr Salmond is told about the investigation.
April 2 - Nicola Sturgeon meets Mr Salmond at her home in Glasgow. The first minister's chief of staff Liz Lloyd is present at the meeting, where Mr Salmond reveals that he is under investigation. Ms Sturgeon insists this is a party meeting, rather than a government one.
April 23 - Ms Sturgeon speaks to Mr Salmond on the phone.
June 6 - With Mr Salmond seeking a further meeting, Ms Sturgeon writes to Ms Evans to notify her that she knows about the investigation - and flagging up that her predecessor is considering legal action.
June 7 - Ms Sturgeon meets Mr Salmond in Aberdeen, ahead of the SNP conference.
July 14 - Ms Sturgeon and Mr Salmond meet again at the first minister's Glasgow home.
July 18 - A third phone call takes place between Ms Sturgeon and Mr Salmond. She later says this is the last time she spoke to him.
August 22 - Mr Salmond is informed that the government inquiry is complete. Ms Evans tells him and Ms Sturgeon that she intends to make the fact of the complaints public.
August 23 - The Daily Record newspaper breaks news of the allegations against Mr Salmond via a tweet. Within half an hour, Mr Salmond tweets a statement denying misconduct and calling some allegations "patently ridiculous".
He announces that he is launching a judicial review of the way the investigation was handled, calling it "unjust". He singles Ms Evans out, saying that the "procedure as put into operation by the permanent secretary is grossly unfair and therefore inevitably will lead to prejudicial outcomes".
August 24 - Ms Sturgeon publishes a statement on Twitter, confirming that complaints were made and were investigated under the new procedure. She stresses that while she has been "aware for some time of the fact of the investigation - initially from Alex Salmond - I have had no role in the process".
She also states that "this focus on process cannot deflect from the fact that complaints were made that could not be ignored or swept under the carpet".
Ms Evans then releases a statement about the judicial review, saying the government will "defend its position vigorously" - and claiming that Mr Salmond's statement "contains significant inaccuracies which will be addressed in court".
August 25 - After Mr Salmond complains that confidential information about the probe has been leaked to the media, the Scottish government insists its investigation was "entirely confidential". The former first minister holds a press conference, saying that "I have not sexually harassed anyone".
August 26 - Ms Sturgeon posts a further statement on Twitter, saying the SNP has "no legal basis at this time to suspend Alex Salmond's membership".
August 29 - Mr Salmond resigns from the SNP, saying he wants to avoid internal division in the party and "remove this line of opposition attack". He says he will apply to rejoin once he has cleared his name.
He also launches a crowdfunding appeal for his judicial review, characterising it as being "against the permanent secretary to the Scottish government". The crowdfunder swiftly raises double its £50,000 target.
September 14 - Police confirm they have launched an investigation into the complaints against Mr Salmond. This is entirely separate from the government's investigation and the judicial review process.
September 20 - The Scottish government confirms it will contest Mr Salmond's judicial review in court. A spokesman says: "We are confident that our processes are legally sound, and we will vigorously defend our position in court."
November 6 - The judicial review calls in court for the first time for a preliminary hearing, with a full four-day hearing fixed for the following January.
November 12 - The separate police investigation into Mr Salmond continues, with staff at Edinburgh Airport spoken to about a separate alleged incident dating from 2008. Mr Salmond denies "all suggestions of misconduct at any time".
December 14 - Mr Salmond scores an early legal win in a preliminary court hearing, forcing the government to hand over documents related to its investigation.
January 8, 2019 - One week before the full judicial review is due to begin, a hearing is abruptly called at the Court of Session in Edinburgh, where the government concedes defeat.
The government's lawyers accept that the investigating officer appointed to the case had had previous contact with the complainers, invalidating the whole inquiry. Lord Pentland rules that the investigation's reports should be set aside, and the government promises not to publish or disseminate them.
Ms Evans releases a statement apologising to "all involved" for the collapse of the investigation, blaming a "single procedural flaw". She says the process itself is still "robust", and says the complaints against Mr Salmond could still be re-investigated - after the police probe is complete.
Speaking to the media outside court, Mr Salmond repeatedly calls for Ms Evans to consider her position, saying she is responsible for an "abject humiliation" and a "surrender" on the part of the government.
Later in the day, Ms Sturgeon makes a statement at Holyrood echoing Ms Evans' apology and her defence of the process. She sets out details of her contact with Mr Salmond during the inquiry, adding: "I was always clear that I had no role in the process. I did not seek to intervene in it at any stage - nor indeed did I feel under any pressure to do so."
January 10 - Under questioning from opposition parties about her meetings with her predecessor, Ms Sturgeon denies being part of a conspiracy against Mr Salmond or colluding with him during the probe.
The Conservatives call for a parliamentary inquiry into the "botched" investigation, while Labour claim Ms Sturgeon has broken the ministerial code, and formally call on her to refer herself to the independent panel overseeing it.
It is confirmed that Mr Salmond reported the government to the data protection watchdog after details of the allegations against him appeared in the media.
January 13 - Ms Sturgeon refers herself to the independent advisors to rule on whether she breached the ministerial code in her meetings with Mr Salmond.
January 14 - The first minister's spokesman accuses Mr Salmond's team of "an attempt to smear the first minister" through newspaper stories, amid claims that Ms Lloyd knew of the complaints ahead of the April 2 meeting.
January 15 - MSPs agree to hold a Holyrood inquiry into the government's handling of the complaints against Mr Salmond.