He had been tipped as a possible successor to Nicola Sturgeon, but now Derek Mackay has been forced to quit the Scottish Government.

The 42-year-old stepped down as Scottish Finance Secretary just hours before he was due to unveil his Budget for 2020-21, after a newspaper reported he had sent hundreds of messages to a 16-year-old boy.

It comes more than two decades after he began his career in politics, being elected as a councillor in Renfrewshire in 1999.

It made him the youngest male councillor in Scotland, having been elected at just 21.

Mackay went on to become leader of the council's SNP group and took them into power in the area for the first time in 2007 – at which point he became leader of the council.

WATCH: Nicola Sturgeon's statement to Holyrood on Derek Mackay

He used his role to build a national profile within local politics, becoming the SNP group leader at Cosla – the organisation which represents Scotland's local authorities.

In 2011 he was elected to Holyrood as MSP for Renfrewshire North and West.

That same year he joined the Scottish Government, becoming minister for local government and planning.

A reshuffle after Nicola Sturgeon became First Minister in 2014 saw him appointed transport minister.

He was further promoted to the Cabinet after the 2016 Scottish election, taking the job of Finance and Economy Secretary.

He was previously married and has two children, but in 2013 he came out as gay. He later described that as the "most difficult thing I've ever had to deal with".

READ MORE: No criminal complaints filed against Derek Mackay, Police Scotland say

During his time as finance secretary, he was responsible for introducing new Scottish income tax rates, including a new "starter rate" set at 19p for lower earners.