Media playback is unsupported on your device Media caption Carolyn Harris said she will work for those who backed Julie Morgan in the contest.

Carolyn Harris has won the Welsh Labour deputy leadership election.

Ms Harris's victory comes despite more party members backing her rival Julie Morgan. The Swansea East MP won more votes among AMs and MPs, and groups linked to the Labour party including unions.

She said she will "campaign for every issue that affects the good people of our country".

The result was announced at Welsh Labour conference in Llandudno.

The announcement came before the dramatic announcement that First Minister Carwyn Jones would step down in the autumn.

The election - the first for a deputy leader in Welsh Labour - was held under an electoral college, where the votes of party members are weighed alongside affiliated organisations and elected parliamentarians.

In the overall result, Ms Harris won 51.5% of the vote versus 48.5% for Cardiff North AM Ms Morgan.

It is likely to fuel the debate over whether leadership elections in the party should be held under the one member one vote (OMOV) system, where members' votes are weighed equally and which was used for the election of UK Labour leader Jeremy Corbyn.

One Welsh Government cabinet member said in the wake of the result that the electoral college was an "affront to democracy".

'Working for you'

In her acceptance speech, Ms Harris told conference: "I've got a big heart, I've got a big mouth, and you've trusted me to give you the big platform. I will lead you in campaigning.

"I will campaign for every issue that affects the good people of our country.

"I said I will be a voice for all members, and I will."

In a gesture to reach out to those who did not back her, she said: "Those who voted for Julie, I need you to know, I will be working for you as well."

Image caption Carolyn Harris beat Julie Morgan in the Welsh Labour deputy leadership election result, announced in Llandudno

Analysis by BBC Wales political editor Nick Servini

Carolyn Harris was in a conciliatory mood as she tried to reach out to Julie Morgan's supporters in her victory speech.

Those watching in the conference hall know the result will increase the resolve of many to bring in one member one vote.

History has repeated itself in a poignant way.

What happened to Rhodri Morgan when he lost the Welsh leadership contest against Alun Michael, despite winning the party membership, has now happened to his widow Julie.

Carwyn Jones has tried to head some of this anger off at the pass with plans for a democracy review so that a decision can be made at the conference next year.

That should take some of the heat out of the situation, but not all.

The electoral college system saw votes weighted equally from three separate groups.

Ms Harris won 20.14% from members of organisations linked to the Labour party, including unions, while Ms Morgan won 13.19% of the group.

Of MPs and AMs, Ms Harris won 19.75% of the vote, versus 13.58% for Ms Morgan.

But Ms Morgan won 21.73% of the vote of members, versus 11.6% for Ms Harris.

Mr Jones said: "I want to congratulate Carolyn Harris on her win and I look forward to working with her very much.

"I also give my heartfelt thanks to Julie for her campaign, and the superb contribution she has already made to Welsh Labour and will continue to make in the years ahead."

But Jenny Rathbone, Labour AM for Cardiff Central who had backed Mrs Morgan, tweeted that the result "will certainly rekindle the demand for one member one vote".

The result was followed by a fringe event calling for OMOV elections in Labour at conference, headed by a panel that included three cabinet ministers - Mark Drakeford, Lesley Griffiths and Julie James.

Finance secretary Prof Drakeford said: 'The system is rotten." The contest was "the day we lost the battle to win the war", he said.

Ms Griffiths said the party's electoral college was "an affront to democracy".

'Travesty'

Jon Lansman, chairman of the Momentum internal Labour party organisation which supports Jeremy Corbyn, congratulated Ms Morgan for winning the members' vote.

"The process was a travesty of democracy and insults the people of Wales," he said on Twitter, accusing the Welsh Executive of deliberately choosing to limit members say to one third of the overall vote.

Cardiff West constituency Labour Party chairman David Davies said: "The members overwhelmingly support [one member one vote] and this results shows beyond doubt that the college must go. And it will."

Mrs Morgan had called for the introduction of OMOV, which the party's ruling executive rejected last year, while Ms Harris had supported retaining the current electoral college.