Dr Catherine Calderwood agreed to step down just hours after “unreservedly” apologising for the trip to Fife and withdrawing from giving public briefings.
She said that she took the decision following a discussion with first minister Nicola Sturgeon, who said that the issue “risks undermining confidence” in the government’s advice.
“I am deeply sorry for my actions and the mistakes I have made,” Dr Calderwood said in a statement.
“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. 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.
“It is with a heavy heart that I resign as Chief Medical Officer. I will work with my team over the next few days to ensure a smooth transition to my successor.”
It came after The Scottish Sun published photos of Dr Calderwood and her family near a coastal retreat in Earlsferry, more than an hour away from Edinburgh, late on Saturday.
Dr Calderwood was visited by local police in Earlsferry and issued a warning “about her future conduct”, said Police Scotland.
Ms Sturgeon, who had been criticised for “defending the indefensible”, accepted the resignation over the “very serious mistake” but praised Dr Calderwood’s “highly valuable contribution to health in Scotland”.
She 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. Also, as I said earlier, her advice to me on coronavirus will be missed – which is why she will work to ensure a smooth transition in the days ahead.
“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.”
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies