She had called for the vote herself after months of inner-party friction.
Her rival, former Prime Minister Kevin Rudd, takes her place as party leader, after winning the internal ballot by a margin of 57 to 45 votes, according to an ALP spokesman.
He is now Australia’s de facto prime minister and could be sworn in within hours, if Australian Governor-General Quentin Bryce approves him for the office. The governor-general shares the role of head of state with Britain’s Queen Elizabeth II.
In a news conference after the vote, Gillard said she was grateful to have had the opportunity to lead her country.
“This privilege was truly humbling. I thank the Australian Labor Party for that privilege and I thank the Australian people for their support,” she said.
“When I first put myself forward for consideration for Labor leader in 2010, I had the overwhelming support of my colleagues to do so. I thank them for that. And I thank them for giving the opportunity to me not only to serve the nation but to serve as the first female prime minister of this country.”
Gillard said she had written to the governor-general to inform her of the ballot result and asking her to commission Rudd as prime minister. She will go to see Bryce later Wednesday.
Rudd is widely popular with Australian voters, who go to the polls in September to pick a new parliament and government. The ALP has not felt confident it could take an election victory with Gillard at its helm.
Supporters within the ALP circulated a petition calling for Rudd to challenger Gillard’s leadership, but he initially refrained. In the meantime, at least eight of the ministers in Gillard’s Cabinet resigned, purging decades of experience from her government.
This week the prime minister had had enough. Despite no official challenge from any rival, she put her power on the chopping block and handed her party the ax.
“I do think it’s in the best interests of the nation — and in the best interests of the Labor Party — for this matter to be resolved,” she said as she called the vote.
Reluctant Rudd
In a jab at her rival, Gillard complained in an interview with CNN affiliate Sky News Australia this week that no one had approached her to mount a leadership ballot in a traditional manner.
“Call me old fashioned, but the way in which these things are normally done is a challenger approaches the leader of the Labor Party and asks them to call a ballot for the leadership, you shake hands and then a ballot is held,” she said.
Gillard called for any challengers to put their names on the ballot, which would be the last one she would call to challenge her position.
Three hours before the vote, Rudd picked up the gauntlet.
“Various ministers have been free and frank in their public advice to me as to the desirability to contest the leadership in recent days. For the nation’s sake, I believe it’s time for this matter to be resolved,” he said in a statement sent to journalists.
The showdown was set in stone.
Rudd has said that he will not use his win against party rivals.
“Every effort I have in my being will be dedicated to uniting the Australian Labor Party. No retributions, no pay backs, none of that stuff. It’s pointless, it’s old politics,” he said.
Loser leaves
In March, Gillard threw down a similar challenge to her power as the rivalry sapped strength from her government. Rudd refused back then to challenge her, and she won the vote of confidence from her party and kept her job.
But she continued to lose support within her party.
In her interview with Sky News, Gillard said the loser of Wednesday’s vote should get out of the way for the sake of a functioning government.
“If you win, you’re Labor leader,” she said. “If you lose, you retire from politics.”
In her post-vote news conference, Gillard confirmed she will not seek to retain her constituency seat in September’s general election.
CNN’s John Raedler, Brian Walker and Elizabeth Joseph contributed to this report