Scotland’s former finance secretary has resigned from the SNP after he was suspended from the party over messages he sent to a teenage boy.

Derek Mackay resigned as finance secretary hours before he was due to deliver the Scottish budget on February 6 last year following reports he sent hundreds of messages to a 16-year-old boy on social media.

The Scottish Sun reported Mr Mackay befriended the teenager on Facebook and Instagram and sent him 270 messages.

The Renfrewshire South and West MSP was suspended from the SNP pending further investigation but continued to sit as an independent.

Derek Mackay expenses
Derek Mackay continued to sit as an independent for Renfrewshire South and West (Lewis McKenzie/PA)

He told the party he is resigning to “focus on the recovery of my mental health and serving my constituents”.

An SNP spokesman 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 wrote to the SNP National Secretary earlier this week to inform the party of his decision.

In the letter he wrote: “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.”

Announcing his resignation on budget day last year, Mr Mackay admitted he had “behaved foolishly” and apologised “unreservedly” to the individual involved and his family.

Police Scotland carried out an investigation into the messages Mr Mackay sent to the teenager and concluded no crime was committed.