Alex Salmond has resigned from the Scottish National Party (SNP), following allegations of sexual harassment.
It was reported last week that Mr Salmond is under investigation over his behaviour towards two staff members while he was first minister.
The former first minister denies the harassment claims and is suing the Scottish government over its complaint process.
As well as refuting the alleged harassment, he has also said he "absolutely rejects any suggestion of criminality".
In a lengthy post published online on Wednesday evening, Mr Salmond said he believes Scottish First Minister Nicola Sturgeon "feels under pressure from other parties" to suspend him from the party - and has resigned "to remove this line of opposition attack".
He suggests that the party being forced to suspend him "would cause substantial internal division".
He explained: "In my letter to the National Secretary I state that it is my absolute intention to reapply for SNP membership just as soon as I have had the opportunity to clear my name. I hope that is by the end of this year.
"In the meantime I would urge no one else to relinquish their SNP membership."
He also began a crowdfunding effort for his legal challenge, already raising more than his initial goal of £50,000.
'Huge sadness'
In a statement, the current First Minister said she felt "huge sadness" about the situation.
Mrs Sturgeon observed: "Alex has been my friend and mentor for almost thirty years and his contribution to the SNP and the independence movement speaks for itself."
She added: "However, the hard fact remains that two complaints were received by the Scottish Government that could not be ignored or swept under the carpet.
"Complaints must be investigated without fear or favour, regardless of the seniority of the person involved."
Statement. pic.twitter.com/PrNfXPCfKx
— Nicola Sturgeon (@NicolaSturgeon) August 29, 2018
Mr Salmond served as Scottish first minister between 2007 and 2014, resigning in the wake of the unsuccessful Scottish independence referendum.
He then returned to Westminster, but lost his seat in last year's general election.