The deputy leader of the Scottish National party, Keith Brown, said it would be“very difficult” for Derek Mackay to remain at Holyrood after repeatedly texting a 16-year-old boy.

Brown said the former finance secretary, who resigned in disgrace on Wednesday, was in an extremely serious situation after admitting he had contacted the schoolboy repeatedly on Facebook and Instagram.

Mackay, 42, was suspended from the SNP on Thursday by Nicola Sturgeon, the party leader and first minister, but Brown told BBC’s Politics Scotland programme the party could not force Mackay to quit as an MSP.

“As to whether he stays in the parliament, it is entirely his decision,” Brown said. “I think it’s very difficult to see how he can continue but it’s his decision.”

Mackay resigned as finance secretary on Wednesday night on the eve of his annual budget announcement, after the Scottish Sun published the details of 270 unsolicited messages he sent the teenager.

They included messages calling the boy “really cute”, saying he was “looking good with that new haircut”, inviting him to dinner and asking him to confirm their messages remained private.

Mackay, seen as a future contender for the SNP leadership, also faces a police investigation.

Police Scotland said it had since spoken to the 16-year-old but was still assessing the issue, since no formal complaint had been made. The boy told the Sun he felt “grossed out” by some of Mackay’s messages.

Mackay, who has two sons, has also deleted his Facebook and Twitter accounts, and restricted access to his Instagram account, raising concerns that could impede any investigations into his alleged behaviour.

Another SNP minister who resigned for allegedly harassing two women, Mark McDonald, was expelled by the party in 2018 but remained at Holyrood as an independent, routinely voting alongside his former party.

Unlike Westminster, there is no recall system for MSPs, allowing voters to demand a byelection, but Brown said it would be interesting if that was proposed for Holyrood.

Mackay, once one of Scotland’s youngest councillors, held the seat of Renfrewshire North and West with a very comfortable 7,373 (24%) majority in 2016.

Brown said the scandal had shocked the party, which had now embarked on an extensive investigation. “It’s an extremely serious situation, serious for the young individual involved, and it’s being treated very seriously by the government and by the first minister,” he added.

Opposition parties pointed to claims Sturgeon had warned Mackay not to drink heavily at SNP conferences, which he chaired for eight years, because of alleged concerns about his behaviour at parties. Another party activist said Mackay had bombarded him with texts, and asked him out, when he was 21.

Asked whether he had ever had concerns about Mackay’s behaviour, Brown said: “I wasn’t aware of his text habits if you like and his communicating with people of that age. Completely unaware of that.

“And it came as a shock to people throughout the party. You can see the shock in people, right through not just the SNP but other parties as well.”