Image copyright Getty Images Image caption Derek Mackay is due to deliver the Scottish government's spending plans at Holyrood

The future of Scotland's finance secretary is in question after a newspaper alleged he had been sending messages to a 16-year-old boy.

Derek Mackay is due to present the Scottish government's budget at Holyrood on Thursday afternoon.

The Scottish Sun alleges that he contacted the boy on social media over a six-month period, inviting him to dinner and to attend a rugby event.

Update: Derek Mackay has resigned as finance secretary.

The BBC has contacted the Scottish government and Mr Mackay for comment.

The newspaper details allegations that the 42-year-old politician contacted the boy "out of the blue" and sent about 270 messages on Instagram and through Facebook.

It has published a list of conversations involving Mr Mackay and the boy.

In one of the exchanges it is claimed that Mr Mackay told the teenager he was "cute". In another the boy confirmed he was 16 and tells Mr Mackay "not to try anything".

The paper also quotes the boy's mother calling for Mr Mackay to be removed from his post.

Mr Mackay, who has been widely tipped as a future first minister, came out as gay when he left his wife in 2013.

The allegations come on the same day he is due to present the Scottish government's spending plans for the next years at Holyrood - a major set piece event.

He had signalled his intention to spend more on projects to tackle climate change in his budget, but will need the support of other parties to pass his plans.

Mr Mackay would have been putting the finishing touches to his preparations when he was contacted by the Scottish Sun on Wednesday evening, before the newspaper released the story at 23:20.