Former First Minister Alex Salmond has resigned from the SNP amid sexual misconduct claims, which he denies.

Mr Salmond announced the decision on Wednesday evening in a video posted on YouTube.

He said his resignation was to avoid a potential internal split in the SNP ranks.

Two people have made allegations about the former First Minister, who strongly denies ever sexually harassing anyone.

READ MORE: Alex Salmond begins legal action over handling of sexual misconduct claims

He is seeking a judicial review of a new complaints procedure that was introduced by the Scottish government in December.

The Scottish government said it would "defend our position vigorously".

He has also announced a crowdfunding campaign in a bid to raise £50,000 to cover his legal costs.

The allegations about Mr Salmond's conduct towards two staff members in 2013, while he was in office, first emerged last week when the former MP released a statement prompted by an inquiry from the Daily Record.

The newspaper published what it claimed were details of one of the complaints over the weekend.

Mr Salmond said he planned to reapply for SNP membership when he "clears his name".

Police Scotland confirmed on Friday that the complaints have been passed to the force.

TRANSCRIPT OF MR SALMOND'S VIDEO MESSAGE

I HAVE been a member of the Scottish National Party for 45 years, 20 of them as party leader and seven as First Minister of Scotland. I hope I have done the party and the broader cause of independence some service.

Apart from a political spat back in the 1980s, that has been a period of continuous membership. I truly love the SNPand 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.