Kevin Rudd has ousted Julia Gillard as leader of the Australian Labor Party and Prime Minister after a vote by the party caucus on Wednesday night. The vote was 57 to 45 in his favour.
Ms Gillard called the vote earlier on Wednesday amid disastrous polling for the party and continuing speculation about her leadership.
She said then that whoever lost should quit parliament. Mr Rudd also said he would quit politics if he lost the leadership vote.
In announcing the contest, Ms Gillard said it was in the best interests of the nation and the ALP for the issue to be resolved.
Kevin Rudd's dramatic return as Prime Minister came almost three years to the day after he was dumped in favour of Julia Gillard, Australia's first female prime minister, and following two aborted leadership attempts in 2012 and March this year.
He had consistently promised up until Tuesday that he would not challenge again. However, on Wednesday he said he was prompted to stand because of fears the party faced an electoral wipeout later this year, AAP reports.
A series of opinion polls had shown a Gillard-led election campaign could have seen Labor lose up to 35 seats, giving the conservative opposition a massive majority in the 150-member parliament.
Mr Rudd was seen in the polls as being more popular with voters and could give Labor an outside chance of victory at the elections, scheduled for 14 September. However, there is speculation that he will now call an early election within a month.
On Tuesday, Ms Gillard gave her colleagues a lukewarm assessment of Labor's chances of staying in government after the election. With opinion polls consistently showing the party losing at least 30 seats, she did not talk up the prospects of it retaining office.
New Zealand's Prime Minister John Key said on Wednesday night the relationship with Australia is the country's closest and most important, and he looks forward to working with Kevin Rudd in the area of trade, economics, defence and security. Mr Key also said that Julia Gillard has been a good friend to New Zealand.