Raised in Renfrewshire, Derek Mackay attended Renfrew High School and the University of Paisley.
His family briefly became homeless during his early teens, an experience he said shaped his outlook – as did the campaign against a new incinerator in the area.
The young Mr Mackay studied shipping management, but always had his eye on a career in politics – he joined the SNP at 16, and served as national convener of the party’s youth wing.
He was elected to his local Renfrewshire Council in 1999 at the age of 21 – the youngest male councillor in the country at the time. He went on to lead the council between 2007 and 2011.
Mr Mackay became MSP for the newly-created constituency of Renfrewshire North and West in 2011, beating Labour with a majority of 5.7%.
Before the year was out he was local government minister, with Alex Salmond drafting him into government in a December reshuffle.
When Nicola Sturgeon took office in 2015 he became transport minister, with responsibility for major projects such as the construction of the Queenferry Crossing.
After the 2016 Holyrood election – which saw him increase his majority to a very comfortable 24% – he was promoted to finance secretary. He initially shared the economy brief with Keith Brown, but absorbed the full role in the next reshuffle.
The role saw him drawing up the Scottish budget each year – deciding the fate of £30bn of funding.
Mr Mackay admitted occasionally feeling “imposter syndrome” at the top of politics.
He told Holyrood Magazine: “I don’t think it’s a bad thing to admit that there are times when I don’t think I’m good enough to do the job”. But he quickly added that “having met my so-called Imperial Masters [at the Treasury], I am feeling perfectly apt and perfectly up to the job”.
The 42-year-old also became a major figure in the SNP, serving as business convener for seven years between 2011 and 2018 – a period when the party’s membership exploded in size.
This role saw him oversee management of the party via its National Executive Committee, and he became a popular figure with the quickly-growing membership while chairing conferences.
Mr Mackay came out as gay in 2013 and separated from his wife, with whom he has two sons.
Having served at the top of Ms Sturgeon’s government, many bookmakers had tipped Mr Mackay as the favourite to succeed her some day.
But his downfall has been even swifter than his rise through the ranks at Holyrood.
After the Scottish Sun published transcripts of hundreds of text messages he had allegedly sent to a 16-year-old boy over a six-month period, he tendered his resignation to Ms Sturgeon “with immediate effect”.
He said he had “behaved foolishly” and was “sorry to have let colleagues and supporters down”.
His exit has come on the very day he was due to set out his latest tax and spending plans at Holyrood. He will now see the budget delivered by another rising star of the SNP, his junior minister Kate Forbes.