Julia Gillard
Australia's Prime Minister Julia Gillard has lost a party leadership ballot to Kevin Rudd

Australian prime minister Julia Gillard has lost a party leadership ballot against the man she ousted three years ago, Kevin Rudd.

Gillard, who pledged to leave politics if she was defeated in the ballot, lost Labor lawmakers' support by a margin of 57 to 45 in a closed-door meeting in the Australian capital of Canberra.

If she leaves office, the new party leader might be forced to call an early election.

Gillard surprised political observers by calling the leadership ballot in an effort to close Labor ranks ahead of September's general elections.

Rudd's supporters were pushing for a leadership change as Labor fell behind the opposition Liberal Party of Australia, led by Tony Abbott, in opinion polls.

"The truth is many, many MPs have requested me for a long time to contest the leadership of the party because of the parlous circumstances we now face," Rudd said.

"We are on course for a catastrophic defeat unless there is change. And so I am saying to you, to the people of Australia, I'm seeking to respond to your call that I've heard from so many of you to do what I can."

Before the vote Gillard was confident she could win. "I wouldn't be putting myself forward unless I had a degree of confidence about the support of my parliamentary colleagues," she said.

However, her chances narrowed 20 minutes before ballots opened when her influential erstwhile ally Bill Shorten announced he was supporting Rudd.

Kevin Rudd
Kevin Rudd (Reuters) Reuters