First Minister Nicola Sturgeon said she had accepted Mr Mackay's resignation, adding: "Derek has made a significant contribution to government, however he recognises that his behaviour has failed to meet the standards required."