CANBERRA, Australia — Kevin Rudd has wrenched back the job of Australian prime minister from the former deputy who took it from him three years ago, possibly just in time to lead his party to a defeat in upcoming elections.

He was sworn in Thursday and urged fellow lawmakers to be "a little kinder and gentler" toward each other following the internal coup that ousted Julia Gillard, the country's first woman prime minister.

Rudd, a Mandarin-speaking former diplomat, forced Gillard out Wednesday in nearly the same way she ousted him in 2010. Each faced a party leadership vote in the face of a revolt from Labor Party lawmakers, but while Rudd did not contest Gillard's earlier challenge, she went ahead with a vote that she lost 57-45.

Gillard tendered her resignation Wednesday night.

In a brief statement to Parliament two hours after he was sworn in as national leader, Rudd praised Gillard's "major reforms" on issues such as industrial law and school literacy testing, as well "her great work as a standard bearer for women."

Rudd's ouster had created a rift in the Labor Party and endless infighting. He had tried twice previously to oust Gillard, last year and in February. Many took the fact that he never posed for a Parliament House portrait, as other former prime ministers had done, as a sign that he never gave up on returning.

"As we all know in this place, political life is a very hard life; a very hard life indeed," Rudd told Parliament.

"Let us try — just try — to be a little kinder and gentler with each other in the further deliberations of this Parliament," he added.

Rudd's way back to leadership was paved with the Labor Party's dismal opinion polling under Gillard, ahead of elections she had set for Sept. 14 but that Rudd could schedule as early as Aug. 3. Australians favor Rudd over Gillard, and while the conservative opposition is still favored to win the next election, Rudd's leadership could help avoid a landslide defeat.

Rudd had warned that Labor was facing its worst election defeat under Gillard's leadership in the 111-year history of the Australian federation.

Gillard lacked Rudd's charisma, and although many Labor lawmakers preferred her style, her deepening unpopularity among voters compelled a majority to seek a change.

Opposition leader Tony Abbott demanded an explanation from Rudd of why Gillard was deposed with elections looming. Abbott also called for an election date to be confirmed.

"Politics is a tough business and sometimes it is far more brutal than it needs to be," Abbott said.

"This is a fraught moment in the life of our nation. A prime minister has been dragged down; her replacement owes the Australian people and the Australian Parliament an explanation," he added.

Rudd's office could not immediately confirm whether Rudd would replace Gillard in a visit to Indonesia that had been scheduled for next week.

Governor-General Quentin Bryce commissioned Rudd as prime minister on Thursday, what is likely to be Parliament's last day before elections.

Anthony Albanese was sworn in as deputy prime minister and Chris Bowen was sworn in as treasurer during the same ceremony. Rudd has yet to say when he will announce his complete Cabinet after seven ministers resigned following Gillard's ouster.

Rudd faces a potential no-confidence vote in Parliament. He probably would survive it, but a loss could trigger an election as early as Aug. 3.

Bryce revealed that she took late-night legal advice on whether she should swear in Rudd. A minority government such as Gillard led has not been seen in Australian federal politics since World War II, and Labor's leadership change raised unique constitutional questions.

While Rudd has the support of his party, Labor has just 71 seats in the 150-seat House of Representatives. Gillard was able to govern with support from some independents and the minor Greens party. They are not obligated to support Rudd, though he did get the backing of at least two independent lawmakers who had not supported Gillard.

Rudd's statement fulfilled a condition set by Bryce that he quickly notify Parliament of his appointment so that lawmakers had an opportunity to take action.

Gillard said after her loss Wednesday that she was proud of her government's achievements, including the introduction of an unpopular carbon tax paid by the biggest industrial polluters. She had been dogged by her pre-election promise never to introduce such a tax.

Gillard's gender was a focus several times during her tenure, and she made international headlines for calling Abbott a misogynist.

She said Wednesday that because of her tenure, "It will be easier for the next woman and the woman after that and the woman after that. And I'm proud of that."