By Angus Cochrane
BBC Scotland News
The contest to become Scotland's seventh first minister will soon begin after Humza Yousaf announced he is to resign.
The embattled SNP leader, under threat from two motions of no confidence in the Scottish Parliament, confirmed his decision in a statement at Bute House.
It followed the collapse of a power-sharing agreement with the Scottish Greens.
Mr Yousaf said he intended to remain as first minister until a new SNP leader is chosen, as was the case when his predecessor Nicola Sturgeon stepped down last year.
In the SNP leadership contest that followed, candidates were required to get 100 nominations from at least 20 local party branches.
The winner was decided by members in a ballot using a single transferable vote system. The contest took about a month to complete, before parliament confirmed Mr Yousaf as the nomination to become first minister.
The next SNP leader would then need to seek parliamentary approval to succeed Mr Yousaf as first minister.
How is a new first minister selected?
The parliament has 28 days to nominate a replacement for Mr Yousaf once his resignation has been accepted by the King.
If there was only one candidate for the parliamentary nomination, they would only need a simple majority of votes in favour to secure the nomination.
In the event that several party leaders put themselves forward for the election, as was the case when Mr Yousaf was confirmed as first minister last year, any candidate that secured more than half of all votes would win the nomination.
If no-one reached that threshold, the candidate with the fewest votes would be eliminated. This process would be repeated until the field was whittled down to two.
At that point, a candidate would only require a simple majority to win the nomination, meaning they only have to gain more votes than their opponent.
Any MSP can nominate a candidate, though it must be seconded by another member. Opposition parties usually field their own leaders as alternative candidates to be first minister, though they do not expect their person to win.
Whoever wins the vote is then formally appointed by the King.
However, should the parliament fail to agree a nomination for first minister within 28 days, the presiding officer would be required to propose a date for an "extraordinary general election".
Could the whole government resign?
Mr Yousaf had been facing two motions of no confidence this week, one tabled by the Scottish Conservatives in his own leadership as first minister and another from Scottish Labour on the government as a whole.
The timing of the votes has not yet been confirmed by parliament and it was unclear whether Mr Yousaf's announcement will lead to either being pulled.
Scottish Conservative leader Douglas Ross told BBC News that Mr Yousaf should have quit with immediate effect and that his party's motion of no confidence could still go ahead.
Scottish Labour leader Anas Sarwar said he would wait to see how the week "plays out" but that the "principle" of his party's no confidence motion in the government "still stands".
If it passed, government ministers would be obliged to stand down. Only a simple majority would be required, meaning the number of members voting for would have to be greater than those opposed.
The parliament would then have 28 days to choose a nominee for first minister. If it was unable to do so, the parliament would be dissolved for an election.
The SNP currently have 63 MSPs, meaning they could be defeated if all MSPs from other parties voted against them.
It remains to be seen whether Mr Yousaf's announcement will ensure the Greens, who have seven seats, do not vote in favour of the no-confidence motion in the government.
Green co-leader Patrick Harvie said: "The Scottish Greens have a long track record of working constructively from opposition and will do so with any First Minister who shares our progressive values and who can secure our confidence."