Media playback is unsupported on your device Media caption Kevin Rudd: "In 2007 the Australian people elected me to be their prime minister and that is a task I resume today with humility."

Kevin Rudd has ousted Prime Minister Julia Gillard as leader of Australia's Labor Party.

He won by 57 votes to 45, in a leadership ballot of Labor lawmakers.

The change comes ahead of a general election due in September, which polls suggest Labor is set to lose.

This is the latest twist in a long and bitter rivalry between the two politicians - but it could be the last as Ms Gillard has said she will now leave politics.

"I will not re-contest the federal electorate... at the forthcoming election," said Ms Gillard, Australia's first female prime minister.

"What I am absolutely confident of is it will be easier for the next woman and the woman after that and the woman after that, and I'm proud of that," she added.

Analysis Kevin Rudd has exacted revenge on Julia Gillard, his one-time friend and deputy who ruthlessly deposed him in 2010. Ever since he was removed from the prime minister's office, he has sought to destabilise her leadership. This has been a very personal feud. For Ms Gillard, it's a dramatic reversal. Three months ago, when she last called a leadership election, her rival could not muster enough support to mount a credible challenge. In the meantime, the Labor government has slipped even further in the polls. Labor is not only one of the most brutal political parties in the world, but also one of the most calculating and pragmatic. Its parliamentarians might not necessarily believe they can win the forthcoming election against the conservative opposition. Many already believe that's a lost cause. But many calculate Mr Rudd will at least prevent an electoral wipe-out, and maybe help save their own seats.

Wednesday's leadership vote makes Mr Rudd the leader of the Labor Party, but not yet prime minister.

Ms Gillard must first write to Governor General Quentin Bryce stating that she is resigning before Mr Rudd can be sworn in.

Despite their bitter rivalry, Mr Rudd praised his predecessor, describing her as a woman of extraordinary intelligence, with great strength and energy.

"Julia, as prime minister and prior to that as deputy prime minister, has achieved much under the difficult circumstances of a minority government," he told a news conference after his victory.

Mr Rudd is more popular with voters than Ms Gillard, and many believe Labor will perform better in the election under him.

Meanwhile, opposition leader Tony Abbott called on Mr Rudd to name an election date, arguing that it should be sooner than 14 September - the date set by Ms Gillard.

"The Australian people are yearning to make a choice. The Australian people are well and truly over this low and dishonourable parliament," he told a news conference.

Limiting losses?

Wednesday's leadership test was the third faced by Ms Gillard since she took office in 2010. She herself ousted Mr Rudd as prime minister in 2010.

The BBC's Nick Bryant in Sydney says Mr Rudd has exacted his revenge, after three years of him and his supporters mounting a destabilisation campaign targeted very much at her.

The ballot followed months of speculation over the party's leadership, and came after a day of drama that saw Mr Rudd's supporters push for a vote.

Media playback is unsupported on your device Media caption Julia Gillard thanked Australians for their support

Shortly before the vote, a key power-broker, Bill Shorten, switched his support to Mr Rudd, saying Labor stood a better chance in the polls with him.

Many people do not think Mr Rudd will win the election but he may mitigate the losses and shorten the time Labor could spend in opposition if the party loses, our correspondent says.

A poll published earlier this month suggested that three cabinet ministers would lose their seats at the poll under Ms Gillard's leadership, but would retain their seats if Mr Rudd was leading the party.

A shake-up in the cabinet is expected following the leadership change.

Deputy Prime Minister Wayne Swan has already quit because of Mr Rudd's victory. He has been replaced by Rudd ally and transport minister Anthony Albanese.