Image copyright Getty Images Image caption Mr Mackay quit just hours before he was due to unveil the Scottish government's budget for the coming year

The Scottish government has defended its handling of the Derek Mackay scandal amid claims it tried to "throw up hurdles" to prevent publication.

Mr Mackay quit as Scotland's finance secretary after the Scottish Sun revealed he sent 270 messages to a 16-year-old schoolboy.

The newspaper says the government demanded to know the name of the boy when it was approached for comment.

It also says it was asked to justify its "intrusion into private life".

Deputy First Minister John Swinney said the government had "simply asked for information to give us the veracity and the substance of the points that were being put to us".

Further newspaper allegations about Mr Mackay's behaviour were published on Friday morning, with the Daily Record reporting that he sent dozens of unwanted messages over a four-year period to a married SNP activist, including one asking: "Got any naughty pics?"

Meanwhile, the Herald claims that Mr Mackay, 42, was banned by First Minister Nicola Sturgeon from drinking during SNP conferences because of concerns over his behaviour.

Mr Mackay has not responded to requests for comment about the allegations against him.

Scottish Conservative leader Jackson Carlaw accused the Scottish government of being "more interested in protecting its own reputation than in the welfare of potential and actual victims".

He added: "A pattern of behaviour is now beginning to emerge, and it's vital the SNP leadership - instead of spinning - acts to establish a complete picture."

The Conservatives have called for a confidential hotline to be set up so people can report any concerns about Mr Mackay.

Ms Sturgeon told the Scottish Parliament on Thursday that she had not known about Mr Mackay's "unacceptable" behaviour until Wednesday evening, and was "not aware of any further allegations" against him.

Mr Swinney, her deputy, told the BBC's Good Morning Scotland programme that he had been "utterly stunned" by the revelations.

He said he had not heard any "revelations of this type" about Mr Mackay in the past, and had no previous concerns about his behaviour.

The Scottish Sun has claimed that the Scottish government's initial response to being told about the allegations against Mr Mackay was to attempt to "throw up hurdles to prevent us from publishing the bombshell revelations".

It said these attempts included: "Demanding to know the name of the 16-year-old schoolboy as well as asking for our 'justification for publication, given the intrusion into private and family life, and correspondence including digital communication'."

The newspaper stressed that it had not identified the boy to the government, which subsequently refused to comment on the allegations.

Media playback is unsupported on your device Media caption Scottish Sun political editor: 'The family are not baying for blood'

Chris Musson, the political editor of the Scottish Sun, spoke to the Podlitical podcast about how the newspaper broke the Derek Mackay story, and what the boy and his family wanted to achieve by going public.

Listen to the full episode here

Mr Swinney insisted that the government had taken "decisive" action once the seriousness of the allegations against Mr Mackay became clear.

He added: "The government became aware of these allegations at about 6pm on Wednesday night, and we simply - because of the significance of what was being put to us - asked for information to give us the veracity and the substance of the points that were being put to us.

"We saw nothing in writing until we saw the first edition of The Sun later on Wednesday evening, so we were simply asking for the detail that we would ask in any situation where allegations are being put to us so that we can be confident about the detail that is being asked."

Media playback is unsupported on your device Media caption Nicola Sturgeon: “It was unacceptable and falls seriously below the standard required of a minister."

Mr Mackay is said to have quit as finance secretary on Wednesday evening, although his resignation was not made public until the following morning. It has been reported that he is in line for a £12,000 severance payment.

He was subsequently suspended by the SNP pending further investigations "when we saw the full detail in the Sun newspaper printed in their edition on Thursday morning", Mr Swinney added.

Mr Mackay now sits as an independent MSP, although he has been urged to stand down completely from Holyrood by opposition leaders who have said his behaviour could "constitute the grooming of a young individual".

Why did Mr Mackay quit?

The Scottish Sun said that Mr Mackay persistently contacted the schoolboy over a six-month period, and told him that he was "cute".

The newspaper detailed allegations that the politician contacted the boy "out of the blue" in August of last year and sent about 270 messages on Instagram and through Facebook.

It has published a list of messages - the most recent of which is from earlier this week - involving Mr Mackay and the boy, in which its says the MSP invited him to dinner and to attend a rugby event.

The newspaper also reported that Mr Mackay contacted the boy several times on Christmas Day, and told him on another occasion that he was "looking good with that new haircut".

In a statement released on Thursday morning, Mr Mackay said: "I take full responsibility for my actions. I have behaved foolishly and I am truly sorry. I apologise unreservedly to the individual involved and his family."

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

His resignation came just hours before he was due to present the Scottish government's spending plans for the next year - a major set piece event in the Scottish Parliament.