Mr Lochhead, who faced huge criticism the wake of the Basic Payment Scheme payment fiasco, signalled his intention to quit as Scotland’s First Minister prepared to reshuffle her leadership team.
In a letter to the First Minister, Mr Lochhead said he wanted to spend more time with his wife, who is battling breast cancer, and their two sons.
"Thank you to both your predecessor Alex Salmond and to yourself for the opportunity to work alongside you during such an amazing period in our party’s history. I have enormous admiration for your leadership and vision,” he said in the letter.
"After much thought in recent months, I have taken the decision that after nine incredible but hectic years as a cabinet secretary the time has come to change the priorities in my life especially in light of recent family circumstances.”
Ms Sturgeon responded by thanking him for his service.
She said: “You have served under both Alex Salmond and myself with distinction and you leave a rich and enduring legacy of achievement in your policy portfolio.
"Chief among this is overseeing the world-leading efforts to tackle climate change which we have brought forward, as well as the unprecedented success new being enjoyed by Scotland’s food and drink industry, which is booming in no small part due to the efforts which you have made on the sector’s behalf.”
Mr Lochhead said on Twitter: "Thank u to great people across Scotland I worked with. Hugely rewarding. Sometimes tough. Always absolute privilege."
Thank u to great people across Scotland I worked with. Hugely rewarding. Sometimes tough. Always absolute privilege. t.co/HKjp6iFMlP— Richard Lochhead (@RichardLochhead)
The MSP for Moray has been under immense pressure in previous months after his department was blamed for major failures in the computer system set up to distribute the 2015 BPS.