South Africa's President Jacob Zuma has called on the African National Congress (ANC) to stop infighting as it decides who will next lead the party.
Mr Zuma warned the future of the ANC was under threat, with South Africans "not happy" with it.
The main contenders to succeed him are the deputy president, Cyril Ramaphosa, and former cabinet minister Nkosazana Dlamini-Zuma, President Zuma's ex-wife.
Whoever wins is likely to succeed Mr Zuma as South African president.
But their bitter leadership battle has raised fears that the ANC could split before national elections in 2019.
President Zuma can remain head of state until those elections. He has been in office since 2009 and South Africa limits the presidency to two five-year terms.
The leadership contest is expected to be a close one, with legal challenges a possibility.
Addressing delegates at the beginning of a gathering to decide the next ANC leader, Mr Zuma said their movement was at a "crossroads".
"Petty squabbling that takes us nowhere needs to take back seat, our people are frustrated when we spend more time fighting among ourselves instead of solving the daily challenges they experience," he said.
Last year's disappointing results for the ANC in local elections, Mr Zuma said, "were a stark reminder that our people are not happy with the state of the ANC".
President Zuma, 75, has been the focus of much controversy and has survived several votes of no confidence in parliament.
He faces numerous corruption allegations but denies any wrongdoing.
In his final speech as ANC president, he asserted that "theft and corruption" were as prominent in the private sector as they are in government. He added that "being black and successful is being made synonymous to being corrupt".
He lashed out at the media, which he said was not "impartial and fair". He also targeted the judiciary, arguing that the courts should have no role in deciding internal party matters.
For the leadership, President Zuma is backing his 68-year-old former wife, Ms Dlamini-Zuma, a veteran politician in her own right who has been critical of the enduring power of white-owned businesses.
Mr Ramaphosa, 65, has spoken out strongly against state corruption and has the backing of the business community.
Recent news that he had a modest lead in the polls was quickly reflected by a rise in the financial markets.
No one spared
Lebo Diseko, Johannesburg, BBC News
Jacob Zuma came out fighting in his speech, hitting out at his critics both inside and outside the party.
It seemed like no one was spared - from ANC members who voted with the opposition to try and remove him, alliance partners who have booed him and called on him to stand down, to "counter-revolutionary forces" he said were intent on reversing the progress made since 1994, when apartheid was brought to an end.
Indeed, that idea of malevolent forces working to bring down both him and the ANC was a thread that ran right through his speech. Mr Zuma placed his fight against his opponents within the wider framework of the fight against apartheid.
He ended his speech by saying "I tried my best", and of those who tried to bring him down "I bear no grudges". He then led the room in song.
This was Jacob Zuma in his element: a rousing speaker, a fierce opponent, delivering cutting rebukes with charm and charisma.
More than 5,000 delegates are taking part in the four-day ANC elective conference at the Expo Centre in Johannesburg.
A vote on the new leader is expected on Sunday.
The first major engagement for the new leader will be the party's anniversary celebrations on 8 January.
The ANC has governed South Africa since the first democratic election more than 20 years ago.
The BBC's Andrew Harding says a question remains whether the ANC is in terminal decline, and what that might mean for South Africa's stability and its future.