Mr Salmond posted a statement on his account.
It read: “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.
“But today I have written to the National Secretary of the Party resigning my membership.”.
He goes on to say that he read “carefully” SNP leader Nicola Sturgeon’s statement on Sunday in which she “made it clear that the SNP never received a single complaint about his personal conduct”.
Mr Salmond continued: “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 a record of 30 years of public service.”
Mr Salmond was accused of sexually harassing two female members of staff during his time as first minister in late 2013. He has denied the allegations made against him.
Police Scotland were handed claims about Alex Salmond’s conduct after he was notified about allegations in March.
The allegations were originally brought to the attention of party officials in January.
One woman has claimed Mr Salmond touched her breast and bottom through her clothes and he only stopped after she told him to multiple times.
He responded by strongly denying the claims saying he has never been a part in any “criminality’.
Alex Salmond said: “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.”
Ms Sturgeon was under pressure to disclose details about her discussions with Alex Salmond after he was accused of sexual harassment.
She has been urged to reveal the times and dates of when their meetings took place, as well as any notes that were taken during their talks.
Ms Sturgeon is also being encouraged to say what she knew of the allegations before they became public and when.
A spokesman for the Scottish Government said: “For legal reasons we are unable to provide further detail at this time. However, in the fullness of time the Scottish Government will seek to make available as much information as it can.”
They also added that the complaints that have been raised “could not be ignored or swept under the carpet”.
This is a developing story, more to follow…