Scotland's chief medical officer has resigned after making two trips to her second home during the coronavirus lockdown.
Dr Catherine Calderwood had apologised for her actions, and initially said she planned to continue in the role.
She was backed by First Minister Nicola Sturgeon, who said Dr Calderwood had made a mistake but should stay in her job.
But Dr Calderwood released a statement later on Sunday saying she had quit.
She said she had done so after speaking again to the first minister, and had agreed with her that the "justifiable focus" on her actions risked distracting from the pandemic response.
The chief medical officer had fronted TV and radio adverts urging the public to stay at home to save lives and protect the NHS, and took part in daily televised media briefings alongside Ms Sturgeon.
Dr Calderwood issued an apology on Sunday morning and said she did not want her "mistake" to distract from the guidance on social distancing.
She later admitted during a televised press briefing that she had also made another visit to the property in Fife last weekend with her husband, but insisted she would be remaining in her post.
Ms Sturgeon said repeatedly during the briefing that she wanted Dr Calderwood to remain in her role as her expertise was "invaluable" during the coronavirus crisis.
The first minister announced later on Sunday that Dr Calderwood would not be be attending any more briefings "for the foreseeable future" and would no longer be the face of the coronavirus public information campaign.
But she said Dr Calderwood would continue to offer scientific and medical advice to the Scottish government on the spread of the virus.
Dr Calderwood then released another statement at about 22:00, in which she said she was "deeply sorry for my actions and the mistakes I have made" and confirmed she was standing down as the country's chief medical officer.
She added: "The first minister and I have had a further conversation this evening and we have agreed that the justifiable focus on my behaviour risks becoming a distraction from the hugely important job that government and the medical profession has to do in getting the country through this coronavirus pandemic.
"Having worked so hard on the government's response, that is the last thing I want."
She also said she would work to ensure a smooth transition to her successor.
Ms Sturgeon said it was "clear" that Dr Calderwood's mistake "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."
The first minister added that the "very serious mistake" made by Dr Calderwood should not detract from her "highly valuable contribution to the medical profession and to health in Scotland".
Police Scotland Chief Constable Iain Livingstone said officers had visited Dr Calderwood and issued a warning about her conduct.
Mr Livingstone said ""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."
Dr Calderwood was appointed as Scotland's chief medical officer in March 2015.
A former national director for maternity and women's health at NHS England, she was a leading medical expert in the inquiry into maternity care at Morecambe Bay.
Her deputy is Dr Gregor Smith, a GP and former medical director for primary care in NHS Lanarkshire.
Scottish Conservative leader Jackson Carlaw described Dr Calderwood's decision to stand down as "embarrassing and inevitable".
Scottish Labour's health spokeswoman Monica Lennon said Ms Sturgeon should have "nipped this in the bud" earlier.