Australian Prime Minister Malcolm Turnbull has appealed for unity after surviving a challenge to his leadership from a senior government colleague.
Mr Turnbull had called the surprise vote himself in a bid to resolve speculation that his leadership was under threat.
In a party room ballot in Canberra on Tuesday, he defeated Home Affairs Minister Peter Dutton.
The prime minister won the vote 48-35, Liberal Party MPs said.
Following the result, he told colleagues: "It's really important that we put our differences behind us and get on with the job of looking after Australians."
Why was there a challenge?
Speculation over Mr Turnbull's future as party leader had escalated in the past few days.
He faced a revolt from conservative MPs over a key climate change policy. That led to him abandoning the plans on Monday in an attempt to blunt conflict within his government.
The PM has also been under long-term pressure due to a series of bad polls and a by-election loss in Queensland.
Polling has suggested the government will suffer a heavy loss in the next general election, which will be held before May next year.
So what happened on Tuesday?
In a bid to clear the air, Mr Turnbull called for a snap vote on the leadership in a party meeting.
Mr Dutton, a leading figure from the party's conservative wing, was nominated as challenger, confirming media reports that he had been gathering support.
Mr Turnbull said he had invited him to remain in his role, but Mr Dutton resigned his cabinet position and will return to the back bench.
Turmoil not over
Jay Savage, BBC News Australia online editor
Mr Turnbull may have prevailed but his margin - just 13 votes - will hardly bring him confidence.
Many expect it will only embolden Mr Dutton to challenge again. Now unconstrained by cabinet loyalty, he will have greater freedom.
But regardless of who is leader, the government is laying bare its disunity - and that most suits Leader of the Opposition Bill Shorten.
What has the reaction been?
Mr Turnbull said he did not "bear any grudge against Peter Dutton".
"My job is to do everything we can to make sure we are united and work together," he said.
"That is why it is very important that today the Liberal Party room has confirmed our leadership of the party."
Mr Dutton said he accepted the result and would support Mr Turnbull, but did not rule out making another challenge.
"I want to make sure that I can support the party and make sure we win the next election," he told reporters.
Deputy leader Julie Bishop said the result showed an "overwhelming vote of support" for the sitting leader.
Are challenges common in Australian politics?
Australian politics over the past decade has been marked by a series of leadership coups, with three sitting prime ministers deposed by party rivals.
Not a single leader in recent times has succeeded in serving a full three-year term as prime minister.
Under the Australian system, as in the UK, the prime minister is not directly elected by voters but is the leader of the party or coalition that can command a majority in parliament.
Mr Turnbull himself became prime minister in 2015 after ousting Tony Abbott in a leadership challenge.
The preceding Labor government also saw two prime ministers, Kevin Rudd and Julia Gillard, oust each other in turn.