South Africa's ruling African National Congress (ANC) elected Cyril Ramaphosa to succeed President Jacob Zuma as the party's leader on Monday evening.
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.
According to the ANC Spokesperson, Mr Ramaphosa defeated Ms Dlamini Zuma by 2,440 votes to 2,261.
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.
A quick look into Cyril Ramaphosa:
He was born in Soweto, Johannesburg, in 1952.
Detained in 1974 and 1976 for anti-apartheid activities
Launched the National Union of Mineworkers in 1982.
Appointed chairman of the National Reception Committee which prepared for Nelson Mandela's release from prison in 1990.
Became an MP and chairman of constitutional assembly in 1994.
Moved full-time into business in 1997, becoming one of South Africa's richest businessmen.
Became South Africa's deputy president in 2014.
Elected ANC leader in 2017
Differences between the two candidates
Mr Ramaphosa, 65, has spoken out strongly against state corruption and has the backing of the business community.
He campaigned as the anti-Zuma candidate, promising to target corruption, and his victory could mean that the ANC decides to recall Mr Zuma as national president in the next few weeks.
The Supreme Court ruled in October that Mr Zuma should face corruption, fraud, racketeering and money-laundering charges.
The ANC recalled Mr Zuma's predecessor, Thabo Mbeki, in 2008 after Mr Zuma replaced him as ANC leader the previous year.
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.
Analysts said that Mr Zuma had backed his former wife.
The ANC election came amid declining support for the party, though opinion polls still suggest backing of about 50 per cent.
There was a touching moment when Nkosazana Dlamini-Zuma came on stage and hugged the man who beat her, by less than 200 votes to the top job in the party, and put a halt to her ambition to be South Africa's first female president.
Supporters of Mr Ramaphosa broke out into song and dance for the better part of the night celebrating the big win.
He has promised to fight rampant corruption and revitalize the economy, a message hailed by foreign investors.