The deputy first minister said he will leave the Scottish Government after nearly 16 years once a new First Minister is appointed following the SNP’s leadership election.
It comes after Ms Sturgeon made the shock announcement that she would resign last month. Mr Swinney was seen as one of her closest political allies.
He is the longest serving Deputy First Minister on record, having held the post for almost nine years, and also served as education secretary and finance secretary. He also served as leader of the SNP in Holyrood between 2000 and 2004 when the party was in opposition.
Ms Sturgeon paid tribute to his “support, wisdom and, above all, friendship”. The departure of the pair marks the end of an era for the modern SNP.
In a letter to the First Minister, Mr Swinney said: “When I joined the Scottish National Party at the age of 15 in 1979, our political prospects were poor and I could scarcely have imagined that over so many years I would have the opportunity to serve Scotland in government in the way I have.
“In all that I have undertaken in government, I have tried to listen carefully to different views and be open to the ideas and thoughts of people in Scotland. I have sought always to transform the life chances of everyone who lives here. I have acted to make Scotland a fairer, more prosperous and more confident country that I believe would be assured with Independence.”
He said he was indebted to Ms Sturgeon for her “leadership, constancy, friendship and loyalty”, adding: “I will continue to faithfully represent my constituents in Perthshire North and look forward to sitting with you on the back benches of the Scottish Parliament to continue our contribution to Scotland’s cause.”
He later said he had made the decision to step away from the Cabinet when his role of interim finance minister came to an end and admitted he had been trying to “get out for quite a while”
Replying, Ms Sturgeon said she felt “a real sense of sadness” when Mr Swinney told her of his decision. She highlighted his achievements and hailed his “friendship and wise counsel” during the pandemic.
She said: “Over almost 16 years in government, more than eight years as Deputy First Minister – indeed, the longest serving Deputy First Minister so far – you have made countless contributions to the good of our people and our country. In short, I could not have wished for a better partner in government than you, and there is no doubt that our Scottish Government would have achieved much less had you not been in it.
“Please accept my thanks for your support, wisdom and, above all, friendship as together with ministers past and present, we sought to make Scotland a better place. As I said when I announced my own departure from office, serving as First Minister has been the privilege of my life - having done so with you by my side as Deputy First Minister has been an honour.
“As for the future, I know you will continue to serve Scotland well and that you will be, as you always have been, a source of good advice and wise counsel to our party, government and movement. I look forward to this new phase - for both of us - as we move to the backbenches and make way for the new generation who will now lead Scotland forward.”
Mr Swinney’s decision to leave the Scottish Government comes as three candidates – Humza Yousaf, Kate Forbes and Ash Regan – are running to replace Ms Sturgeon as SNP leader and First Minister. SNP members will choose their new leader in a ballot later this month, with voting closing on March 27.
Mr Yousaf said it had been “an absolute honour to serve in Cabinet alongside John Swinney”, hailing the Deputy First Minister as a “true giant of the SNP and the independence movement”.
He said: “Our party and our Government owe much of our success to John’s hard work, from securing the council tax freeze in the early days of Government, to expanding childcare as education secretary, finding the funds to help households through the cost of living crisis and enabling me to deliver fair pay for our NHS in recent weeks.”
Meanwhile, Ms Forbes spoke of her “respect and admiration” for Mr Swinney, who took responsibility for public finances for her while she was on maternity leave.
She said: “John Swinney is not only an incredibly able politician, who has put public service at the heart of his career, he’s also somebody who I’d call a friend and is a friend to so many MSPs. I have valued enormously his advice and guidance over the years and I wish him well because he has put in some shift.”
The news overshadowed a further day of campaigning by Humza Yousaf and Kate Forbes as the race to Bute House continued.
Ms Forbes, who attended an event for Ukrainian refugees in Glasgow, said she backed the SNP’s existing policy on currency, and repeated her policy that the next general election would be fought on the grounds of calling for the power to hold an independence referendum to be transferred to Holyrood within three months of the result.
She was also pressed on her decision to back the gender recognition reform bill at the Cabinet in January last year, despite since critiquing it and stating she would not have voted for it had she not been on maternity leave.
The finance secretary insisted her position on the bill had been consistent and when asked whether she was denying the reports she backed the gender bill at the cabinet table, she repeated that cabinet discussions are “confidential”.
In response to the suggestion that was a non-denial denial, Ms Forbes added that “I’m afraid that’s all you’re going to get from me because cabinet discussions are confidential.”
Humza Yousaf, who held a campaign event in Mayfield, Midlothian, said he would launch a £1 million fund to stop community organisations which help people through the cost-of-living crisis going under.
He said this would help community groups like the one he was visiting in Mayfield, which are facing higher operational costs.
Mr Yousaf said: “Projects like this, if they go under, then people will really suffer as a result and we can’t let that happen.”
However, he was also subject to an intervention from Alex Salmond over the ongoing questions about why the health secretary skipped the equal marriage vote in 2014.
Mr Salmond, speaking to Sky News, said it was his “recollection” that Mr Yousaf skipped the vote due to “religious pressure”.
The former first minister and leader of the Alba Party said: “"My memory is that I was contacted 10 days or so before the vote, when the vote was known, and told that Humza was arranging a ministerial appointment."
Mr Yousaf said he was “vocal” about his support for equal marriage at the time, and pointed to comments from then-minister for parliamentary business, Joe Fitzpatrick, who said the health secretary did not raise concerns around the bill at the time.