Scotland's chief medical officer, Dr Catherine Calderwood, has resigned after being criticised for not adhering to coronavirus guidelines by visiting her second home.
Dr Calderwood said she was "truly sorry" for not following the advice she had been giving to others to stay at home.
She was backed by First Minister Nicola Sturgeon to remain in the role, despite visiting her second home in Fife on two consecutive weekends.
However after further conversations with Ms Sturgeon, Dr Calderwood said on Sunday night that she had resigned "with a heavy heart", agreeing the "justifiable focus on my behaviour risks becoming a distraction from the hugely important job".
In a statement, she added: "The most important thing to me now and over the next few very difficult months is that people across Scotland know what they need to do to reduce the spread of this virus, and that means they must have complete trust in those who give them advice."
Dr Calderwood will now work "over the next few days to ensure a smooth transition" to her successor.
ITV News Scotland Correspondent Peter Smith has the latest on the Dr Calderwood's resignation
The First Minister paid tribute to Dr Calderwood, saying she was a "transformational" chief medical officer (CMO).
Mr Sturgeon said: "It is however clear that the mistake she made - even though she has apologised sincerely and honourably for it - risks distracting from and undermining confidence in the Government's public health message at this crucial time. That is not a risk either of us is willing to take.
"Catherine has been a transformational CMO, bringing changes to the way medicine is delivered in Scotland and in particular using her experience to bring an overdue focus to women's health.
"While she has made a very serious mistake in her actions, that should not detract from the fact that as CMO she has made a highly valuable contribution to the medical profession and to health in Scotland, and I have no doubt she will continue to do so in future.
"She leaves office with my thanks and admiration."
Earlier on Sunday evening, Ms Sturgeon confirmed Dr Calderwood was withdrawing from the daily updates and would also no longer feature in the Scottish Government’s advertising campaign.
Dr Calderwood initially apologised after photos of herself and her family near a coastal retreat in Earlsferry were published in The Scottish Sun on Saturday.
Just days earlier, the 51-year-old tweeted a photo of her family at their main residence in Edinburgh as they clapped for the frontline NHS staff working to stop the spread of Covid-19.
The 51-year-old, who was issued with a police warning over her conduct, told the briefing at the Scottish Government headquarters in Edinburgh on Sunday she had also visited the home in Fife last weekend with her husband.
Police Scotland Chief Constable Iain Livingstone said officers had visited Dr Calderwood and issued a warning about her conduct.
Mr Livingstone said in a statement: “Earlier today, local officers visited Dr Catherine Calderwood and spoke to her about her actions, reiterated crucial advice and issued a warning about her future conduct, all of which she accepted.
“The legal instructions on not leaving your home without a reasonable excuse apply to everyone. Social distancing is the key intervention to curtail the spread of coronavirus and it is essential that the instructions are followed to protect each other, take strain from the NHS and save lives.
“Individuals must not make personal exemptions bespoke to their own circumstances.”
Coronavirus: Everything you need to know