South Africa’s ruling African National Congress (ANC) has selected Cyril Ramaphosa to succeed President Jacob Zuma as the party’s leader.
The country’s deputy president defeated former cabinet minister Nkosazana Dlamini-Zuma, Mr Zuma’s ex-wife, after a marathon voting process.
Mr Ramaphosa is in a strong position to become president in 2019 polls.
The leadership battle caused fierce political infighting, raising fears the party might split before the election.
Mr Ramaphosa defeated Ms Dlamini-Zuma by 2,440 votes to 2,261, an ANC spokesperson announced.
The result triggered celebrations among party delegates in Johannesburg and also on the streets of the city.
Media reports said earlier that the announcement had been delayed, with Ms Dlamini-Zuma’s camp demanding a recount.
The voting process started on Sunday.
Mr Ramaphosa, 65, has spoken out strongly against state corruption and has the backing of the business community.
Ms Dlamini-Zuma, 68, had been critical of the enduring power of white-owned businesses and had pledged to tackle what she said was continued racial inequality.
A brutal battle
BBC’s Andrew Harding in Johannesburg
Cyril Ramaphosa was always the frontrunner. He’d won support from more provinces and more branches, and benefited from the fact that as South Africa’s deputy president he was, by tradition, viewed as the heir apparent.
But his victory still has an element of surprise – and will come as a huge relief to his supporters – after a brutal battle for votes within the governing ANC that saw weeks of legal challenges and widespread allegations, right up to the last minute, of fraud, bribery and threats.
Despite his status as an ANC veteran who has been President Zuma’s right-hand man for the past five years, Mr Ramaphosa sought hard not to portray himself as the “continuity” candidate. Indeed he was vocal in his criticism of high-level corruption during his campaign, describing it as “tantamount to treason”.