Nicola Sturgeon's closest aide has announced she is leaving the Scottish Government just hours after Ash Regan's campaign team raised concerns over her involvement with the SNP leadership race with the head of the civil service in Scotland.

A meeting took place this morning between the former community safety minister and her aides with John-Paul Marks, the Permanent Secretary of the Scottish Government.

The role of First Minister Nicola Sturgeon's right hand woman Liz Lloyd was among the issues discussed.

Subscriptions from HeraldScotland

Insiders in Regan's team had told Permanent Secretary John-Paul Marks that her involvement in Yousaf's campaign could breach SNP rules which they say state that no favours or promises can be given to encourage people to work for a candidate.

Just hours after the meeting between Regan's team and Mr Marks, Ms Lloyd announced on social media that she would be leaving when Ms Sturgeon stands down. She said that had always been her intention.

"Personal News: As Nicola Sturgeon’s Chief of Staff and Strategic Adviser over the last eight years it has always been my intention to leave government when she does" she tweeted.

"It has been the biggest honour of my life to work with the First Minister and to have had a unique opportunity to serve the people of Scotland."

She added: "As Chief of Staff at a time when Scottish and UK politics were reset, with a First Minister who guided the country through austerity, Brexit and Covid, is to have been in the room during a pivotal period in Scotland’s political life.

"There will be many people to thank in the coming days before I leave the Scottish Government. After that it will be time to open the door to new projects and new opportunities."

Ms Lloyd announced her resignation 13 minutes after The Herald revealed that Ms Regan's concerns had been brought to the attention of Mr Marks.

As the news broke that Ms Stugeon's aide was to step down, a source quipped to The Herald: "Ash Regan gets things done!"

Earlier the source told The Herald: "We just had a meeting with the Permanent Secretary. We raised the issue about Liz Lloyd."

The insider explained the Regan's team's concerns. "The thing with Liz is that the civil service contracts that special advisors have allows for special advisors to take time off and campaign in general elections, and if it's party elections, so be it. The significant difference here is that this is a party election which will decide on the next First Minister ie [Ms Lloyd's] potential new boss."

The Herald:

First Minister Nicola Sturgeon's aide Liz Lloyd.

The source said SNP rules said that no favours or promises can be given to encourage people to work for a candidate to help them be successful.

"So there are lots of questions here. What has been promised to [Liz Lloyd]? Why is it that Liz Lloyd is being paid by the taxpayer helping Humza Yousaf, the party’s favourite candidate?" they said.

“She is effectively helping to elect her next boss. Even if she is on annual leave, she is effectively campaigning and bringing her resources and her contacts to bear in order to elect Humza, in order to do what – secure her job?"

READ MORE: Tom Devine: 'SNP must choose rejuvenation or acceleration of decline'

Asked by The Herald, before Ms Lloyd announced she was leaving, if Regan's campaign team asked the Permanent Secretary to request Ms Lloyd step down from being involved in the campaign, the insider said: "We don't know how long she's been involved. The damage has been done.

"It just adds to the pattern of behaviour at SNP HQ which we have difficulty trusting."

It emerged earlier this week that Ms Lloyd was helping leadership candidate Yousaf’s campaign amid fears he could be defeated by finance secretary Kate Forbes.

Insiders said that the Scottish Government adviser Ms Lloyd, the long-time chief of staff and so-called “fixer” for the First Minister, is now highly influential in Mr Yousaf’s camp.

Despite Ms Sturgeon publicly remaining neutral in the campaign to succeed her, allies of the current SNP leader have rallied around Mr Yousaf, while Ms Forbes has been attacked by many SNP MSP and MP colleagues for her socially conservative views on issues such as same sex marriage and abortion.

Recent endorsements for Mr Yousaf have included Deputy First Minister John Swinney and SNP Westminster leader Stephen Flynn, raising further speculation that the Sturgeon camp is helping to coordinate backers for Mr Yousaf.

READ MORE: 'Ignorant' Yousaf asks Ukrainian refugees: Where are all the men?

An insider told the Scottish Sun on Wednesday: “Liz is putting Nicola’s wishes into practice. Liz is keeping out of the public eye - she’s not likely to be seen at Humza’s media calls, for example, but she is providing advice.”

Ms Lloyd was Ms Sturgeon’s top special adviser - a taxpayer-funded party adviser, working in government - as Chief of Staff between 2015 and 2021.

She then became Ms Sturgeon’s “Strategic Policy and Political Adviser” in August 2021.

A Scottish Government spokesman told The Herald: "In line with the special adviser code of conduct, special advisers are permitted to assist with party leadership elections, in their own time, while still employed by the Government."      

The SNP directed The Herald to the post on Twitter this afternoon by Ms Lloyd.

Mr Yousaf's campaign team have been approached for comment.

Ms Forbes is due to speak to Mr Marks this afternoon, with Mr Yousaf also invited to discuss his plans for government with the top mandarin.

The contest has been hit by bitter rows between the candidates and their supporters and claims that the race is not being conduted in fair and open manner.

Yesterday the SNP published the number of its members following repeated calls by the campaign teams. it revealed membership of the party had fallen by more than 30,000 in the past two years.

The figure was revealed as outgoing leader Sturgeon stressed the party is not "in crisis" as concerns were raised by two leadership candidates over the integrity of the vote to replace her.

The party announced on Thursday that the membership had dropped to 72,186 as of February 15 this year, compared to 103,884 in 2021.