London (CNN)Scotland's Finance Secretary Derek Mackay resigned on Thursday over a report in Scottish media that he had been sending hundreds of messages to a 16-year-old boy.
Scottish finance secretary quits over alleged messages to teenage boy
His resignation came hours before he was due to deliver next year's budget.
Mackay apologized in a statement Thursday, saying he took "full responsibility" for his "foolish" actions.
"I apologize unreservedly to the individual involved and his family. I spoke last night with the First Minister and tendered my resignation with immediate effect," he said.
"Serving in government has been a huge privilege and I am sorry to have let colleagues and supporters down," he added.
The Scottish Sun first reported the story and published the full text exchanges with the boy, whom Mackay allegedly befriended on Facebook and Instagram.
Scotland's First Minister Nicola Sturgeon accepted Mackay's resignation, saying the former lawmaker "has made a significant contribution to government, however he recognizes that his behaviour has failed to meet the standards required."
Sturgeon later announced during First Minister's Questions on Thursday that Mackay had been suspended from the Scottish National Party (SNP), PA news agency reported.
"I can also advise that this morning he has been suspended from both the SNP and our parliamentary group pending further investigation," she added.