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.

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.

Read More