Derek Mackay has quit the SNP following his suspension from the party.

The SNP launched a disciplinary investigation after the former finance secretary admitted to messaging a 16-year-old boy on social media.

Mr Mackay remained as an independent MSP for Renfrewshire North and West after the scandal last February, with the SNP suspending him from the party and removing the party whip at Holyrood.

READ MORE: Derek Mackay can pick up a ‘golden goodbye’ of £12,000 this week

In a letter to the SNP national secretary, Mr Mackay announced he would not be not seeking to return to the SNP.

He said: "I write to confirm I am not seeking SNP membership and continue to focus on the recovery of my mental health and serving my constituents."

An SNP spokesperson said: "Derek Mackay has resigned his membership of the SNP, bringing the matter to a close.

"As was widely reported last year, Mr Mackay was receiving mental health support, and as a result disciplinary action was paused.

"We wish him well for his recovery."

Mr Mackay’s behaviour came to light after the messages were published in the Scottish Sun just hours before he was due to deliver Scotland’s £40 billion Draft Budget.

READ MORE: Brian Taylor: The Salmond inquiry – will Nicola Sturgeon survive?

Public Finance Minister Kate Forbes, who is now Finance Secretary, had to outline the tax and spending plans in his place.

Police Scotland said he would not face criminal charges over hundreds of messages he sent to a 16-year-old boy saying at the time "there is nothing to suggest that an offence has been committed".

A Scottish Conservative spokesman said: "After more than a year of SNP inaction, Derek Mackay's constituents will be relieved to hear that this sorry episode finally appears to be drawing to a conclusion."