Former SNP leader Alex Salmond has resigned from the party he headed for 20 years amid allegations of sexual harassment.
Mr Salmond, who strongly denies the claims against him, said he was giving up his membership to avoid potential divisions within the party.
The former first minister of Scotland also announced a crowd-funding campaign to help with his costs in a legal action against the Scottish Government.
Opposition parties have attacked the fundraising move as “astonishing” and “unbelieveable”.
Nicola Sturgeon, the current First Minister and SNP leader, voiced her “huge sadness” in the wake of his decision but said she understood why her mentor for three decades had chosen to relinquish his party membership.
Mr Salmond made the revelation in a video message posted online on Wednesday evening.
He stated: “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...
“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.”
Two complaints, fiercely denied by Mr Salmond, were raised in January against him and he was informed of an investigation in March.
Mr Salmond is taking court action against the Scottish Government to contest the complaints process activated against him, with papers lodged at the Court of Session in Edinburgh on Tuesday.
Ms Sturgeon had faced calls from opposition parties to suspend Mr Salmond from the SNP after the allegations emerged, but she insisted there was “no legal basis” to do so.
However, in his latest statement, Mr Salmond indicated he wanted to avoid a potential internal split within the SNP.
He said: “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.”
He added that it is his “absolute intention to reapply for SNP membership just as soon as I have had the opportunity to clear my name”.
In a statement, Ms Sturgeon said: “I feel a huge sadness about this whole situation. Alex has been my friend and mentor for almost 30 years and his contribution to the SNP and the independence movement speaks for itself.
“While the decision to resign has been Alex’s alone, I understand why he has chosen to separate the current questions he is facing from the day to day business of the SNP and the ongoing campaign for independence.”
She added that the complaints received by the Government “could not be ignored or swept under the carpet”.
The allegations about Mr Salmond’s conduct towards two staff members in 2013, while he was in office, emerged last week.
Police Scotland confirmed on Friday that the complaints have been passed to the force.
Mr Salmond reiterated his strong denial of the allegations in the video message, saying: “Let me be clear again. I refute these two complaints of harassment and I absolutely reject any suggestion of criminality.”
Earlier this week, he wrote to Scotland’s top civil servant, calling for an inquiry into how the allegations against him were made public.
“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,” Mr Salmond said in the message.
“It urgently needs to be established who breached that duty of confidence and why.”
He said his “entire focus” is now on preparing for the judicial review proceedings at Scotland’s highest civil court and he has launched a crowd-funder to help with costs.
The Scottish Government has said it will defend its position “vigorously” in court.
Opposition parties have attacked the fundraising campaign.
A spokesman for the Scottish Conservatives said: “Scotland now faces the incredible and unprecedented situation of its most famous former First Minister appealing to SNP supporters for cash to take legal action against the government he used to run.”
Scottish Labour’s Rhoda Grant MSP accused Mr Salmond of “dragging Scotland into the gutter”