In defeat, salvation, in victory, resignation. Kezia Dugdale has announced her resignation as leader of Labour in Scotland, saying it is time for a “new leader with fresh energy” to take the party into the next set of elections to the Scottish Parliament.

The announcement is somewhat incongruous in that, after the Holyrood elections in 2016, Dugdale led the Labour Party to its first third-placed finish since 1918 and the first since the Scottish Parliament was created. She resigns after a a general election in which the party increased its bench strength in the Commons from one to seven, and in which the SNP went from a seemingly unassailable position at Westminster to one in which none of that party’s seats could be considered truly safe.

In part, that’s part because in 2016, the leadership of Scottish Labour was an unattractive post and now it is an attractive one. There are a swathe of seats in Scotland that would, on the smallest of swings from the SNP to Labour, fall into the party’s hands. That increased the desire on the part of Dugdale's internal rivals to remove her from her post.

The good result allows Dugdale to stand down with her head held high, having bequeathed a better position at Westminster than the one she inherited from Jim Murphy, albeit with the caveat of a worse Holyrood position than that of Johann Lamont, her predecessor-but-two. She also secured the long-desired aim of both Welsh and Scottish leaders: the right to pick her own representative on the party’s ruling national executive committee. That means that, for the Lothians MSP, exit no longer meant exit in disgrace.

Whether through honest choice or jumping to avoid being pushed, Dugdale's exit was a near-inevitable consequence of Jeremy Corbyn’s strengthened position after Labour’s forward advance across England, Scotland and Wales at the general election. Unlike her Welsh counterpart, Carwyn Jones, who remained neutral in the 2016 leadership race, Dugdale threw her weight behind Owen Smith’s attempt to replace Corbyn as Labour leader.

That, coupled with a surplus of heavyweights with pukka Corbynite credentials – Neil Findlay, a long term MSP, Alex Rowley, her deputy and Richard Leonard, formerly of the GMB – meant that a challenge to her position was likely in the extreme. A senior Corbynsceptic source described the announcement as a "victory for the hard left".

But while the one member one vote system favours a Corbynite, that Scottish Labour members voted for Owen Smith by 18 points means that a more Corbyn-friendly successor is likely but not guaranteed. Nonetheless, whoever replaces Dugdale will, in public if not in private, have had to demonstrate their support for the Labour leader, a marked contrast to their predecessor. In any case, south of the border, the big prize will be the NEC seat that Dugdale’s successor can appoint – one which would tip the balance of the party’s ruling executive from hung between Corbynsceptics and Corbynites to a narrow majority for Corbyn.