(CNN) -- Kevin Rudd returned as prime minister of Australia on Thursday, three years after being replaced in the office by his then-deputy Julia Gillard.
Rudd challenged Gillard for leadership of the Labor Party on Wednesday and won a 57-45 vote among fellow Labor members of parliament.
In the Australian parliamentary system, the leader of the governing party assumes the position of prime minister and on Thursday morning, in Canberra, Rudd was sworn in for a second time.
Gillard resigned after the party vote on Wednesday night and announced she will leave politics.
A major factor in Gillard's demise -- and in Rudd's Phoenix-like return -- is the election Australia has to hold by the end of this year.
Under Gillard's leadership, Labor was facing overwhelming defeat, according to opinion polls. But the same polls show a Rudd-led Labor Party would fare much better at the ballot box.
Australian Governor-General Quentin Bryce oversaw the swearing-in ceremony at Government House in Canberra. The governor-general represents Queen Elizabeth II as head of state.
Rudd is widely popular with Australian voters, who go to the polls in September to pick a new parliament and government.
Gillard had called for the vote herself after months of inner-party friction.
Rudd, who was elected in 2007 but was ousted by Gillard in a leadership challenge in 2010, said he returns to the office of prime minister with "humility, with honor and with an important sense of energy and purpose."
He said the negative politics holding Australia back in recent years "must stop," and that he will strive to achieve this goal as prime minister.
He also paid tribute to Gillard as "a woman of extraordinary intelligence, of great strength and great energy," and said she had achieved remarkable reforms despite heading a minority government.
In her own news conference, 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."
Tony Abbott, leader of the official opposition Liberal Party of Australia, accused the ALP of focusing on politics over good government.
In a news conference, he said the people of Australia "deserve better than this," and appealed for voters to back his party if they want a strong, stable and unified government.
"Just a couple of simple facts," Abbott said. "In 2007, you voted for Kevin and got Julia. In 2010, you voted for Julia and got Kevin. If you vote for the Labor Party in 2013, who knows who you will end up with?"
Referring to the upcoming election battle, Rudd said he had finally decided to contest his party's leadership because "it's simply not in my nature to stand idly by and to allow an Abbott government to come to power in this country by default."
The internal leadership vote followed months of rivalry and division within the ALP.
Rudd's supporters within the ALP circulated a petition calling for him 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.
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.
Rudd said he would not use his win against party rivals but would focus on uniting the party.
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 the general election.
CNN's Brian Walker, Phil Gast and Elizabeth Joseph contributed to this report