Image copyright PA Image caption Mr Leonard's election was announced in Glasgow

Scottish Labour has announced Richard Leonard as its new party leader after a bitter battle to succeed Kezia Dugdale, who resigned from the role in August.

Party members had to choose between centrist Anas Sarwar and his left-wing rival Richard Leonard.

The contest has been marred by personal attacks, accusations of plots and claims of underhand voting tactics.

Labour leader Jeremy Corbyn said the result could lead to Scottish Labour becoming "a real force for change".

Mr Leonard spoke immediately after the announcement in Glasgow.

He said he hoped a "new generation" would help lead a new movement that was also "founded on our old and enduring idealism".

"That is the unity we can rally around, not simply a call for unity but around a renewed unity of purpose," he said.

"Our purpose today is not just to elect a leader. My aim is to be the next Labour first minister of Scotland."

Image copyright PA Image caption Anas Sarwar congratulated his rival after the announcement

Mr Sarwar commented: "I congratulate Richard on his victory.

"He has my full and unwavering support, and I look forward to campaigning with him to return a Scottish Labour government."

In a vote which saw a 62.3% turnout, Mr Leonard won a 56.7% share, with Mr Sarwar on 43.3%.

Mr Corbyn congratulated Mr Leonard on being elected.

He said: "There is much to do to continue our party's revival in Scotland and many who still need to be persuaded to put their trust in the Labour Party.

"But Richard's campaign offered a challenge to the rigged system that has benefited a wealthy elite and showed how he will lead Scottish Labour to transform society."

He added: "I am confident that under Richard's leadership, Labour will once again be a real force for change in Scotland."

Who is the new leader?

Image copyright PA Image caption Mr Leonard was the odds-on favourite to become the next leader after winning the support of trade unions, including Unite

Bookmakers made Richard Leonard as the clear favourite to become the party's next leader after he secured the support of all the major trade unions, including Unite - which has run a concerted campaign to encourage as many of its members as possible to back him.

The Central Scotland MSP is widely respected within the Labour movement, but had a relatively-low public profile before being persuaded to stand for the leadership.

He has argued that people are "hungry for change", but believes that can only be delivered through "socialism and democracy" rather than "nationalism or patriotism."

And he has firmly ruled out any prospect of a future coalition with the SNP, saying "there will be no ground ceded to nationalism at the expense of progressive socialism under my leadership".

The former GMB union official was born and raised in England, and had a private education - which some critics have claimed could prove problematic for him.

What sparked the leadership contest?

Image copyright Getty Images Image caption Kezia Dugdale had opposed Jeremy Corbyn's re-election as Labour leader

Ms Dugdale became the third Scottish Labour leader to quit since the independence referendum in September 2014 when she resigned suddenly on 29 August - almost exactly two years after succeeding Jim Murphy in the role.

At the time, Ms Dugdale said she wanted to "pass on the baton" to someone else, and denied suggestions that she had been forced out by supporters of Mr Corbyn, who she had openly criticised in the past.

But she later said it would be right to assume that "a lot of internal problems" were the reason she did not tell her deputy, Mr Rowley, that she was quitting until just a few minutes beforehand.

What challenges does the winner face?

Image copyright Scottish Labour Image caption Mr Rowley has been suspended by the party while an investigation is carried out into the allegations against him

The final week of the leadership contest was overshadowed by Mr Rowley stepping down from his interim and deputy leader roles after the Scottish Sun published allegations that he had sent abusive text messages to a former partner.

Mr Rowley denies the claims, but has been suspended by the party while an investigation is carried out.

He had been absent from the Scottish Parliament for the previous two weeks, with party bosses citing a chest infection as the reason.

There have been claims that the party knew of the allegations against Mr Rowley for several weeks, but only suspended him once they appeared in the media.

War of words

The leadership contest itself suggests that Scottish Labour - which is now the third largest party at Holyrood behind the SNP and Conservatives - remains deeply divided.

A public war of words erupted between the rival camps in September after Mr Rowley was secretly recorded discussing the leadership election with a party member while queuing for a fringe event.

The row unfolded as Mr Corbyn was telling the UK party's conference that Labour was "on the way back in Scotland" thanks to its "unifying socialist message".

Meanwhile, supporters of both candidates have raised concerns over the sign-up process for those eligible to vote, with accusations of unfair tactics on both sides.

Whoever ultimately wins the contest looks to have a tough task on their hands to unite the rival factions and make the party a credible challenger to the SNP in time for the next Scottish Parliament election in 2021.

Even surviving in the job that long would be something of an achievement, given that the winner will become the party's fourth leader in little over three years.