This is his statement in full which has been released tonight (Wednesday).
"Apart from a political spat back in the 1980s, that has been a period of continuous membership. I truly love the SNP and the wider independence movement in Scotland.
"They have been the defining commitment of my life. But today I have written to the National Secretary of the party resigning my membership.
"I read carefully Nicola Sturgeon's statement on Sunday and watched her television interview of a couple of days ago. She made it clear that the SNP have never received a single complaint about my personal conduct in my many decades of membership.
"And the Scottish Government have confirmed that they did not have any such complaint before this January, more than three years after I left office as first minister.
"That is the record of 30 years of public service.
"So let me be clear again. I refute these two complaints of harassment and I absolutely reject any suggestion of criminality.
"I believe that all such issues must be treated seriously, confidentially and through a fair process. In this case confidentiality has been broken greatly to my detriment and in a way which puts at serious risk the anonymity of both complainants. It urgently needs to be established who breached that duty of confidence and why.
"It seems obvious that Nicola feels under pressure from other political parties to suspend me from SNP membership, given recent party precedents.
"For my part I have always thought it a very poor idea to suspend any party member on the basis of complaints and allegations. Innocent until proven guilty is central to our concept of justice.
"However, I did not come into politics to facilitate opposition attacks on the SNP and, with Parliament returning next week, I have tendered my resignation to remove this line of opposition attack.
"Most of all I am conscious that if the party felt forced into suspending me it would cause substantial internal division.
"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.
"My entire focus for the next few weeks is preparing for Judicial Review, against the Permanent Secretary to the Scottish Government, the initial stages of which began yesterday.
"My intention is to secure fairness because that is necessary to clear my name. I am enormously grateful for the messages of support and encouragement I have received, including from people of other political persuasions.
"I can assure them all that I will keep on going.
"The costs of a Judicial Review in the highest court in the land are huge. Many have asked how they can help directly. Therefore I have established a crowd-funder to assist with costs.
"All sums received will contribute exclusively to progressing the Judicial Review and any money left over will be used to support good causes in Scotland and beyond.
"Finally, I will continue to serve the independence movement in whatever role and whatever capacity I can.
"It is a rare thing to be devoted to a cause more important than any individual, it is a precious thing to cherish it and my intention now - as it has always been -is to protect and sustain that cause."