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.
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%.
To say the atmosphere inside the plenary was electric would be quite the understatement – the singing inside the hall reached crescendo point as it was announced that Cyril Ramaphosa is the new president of the ANC.
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.
The ANC has been torn apart by infighting of late, and the leadership battle was particularly bitter.
There is much work ahead for the new leader of the liberation movement.
Not only does Mr Ramaphosa need to unite his party, he also needs to convince the electorate that the ANC still represents the issues of the people it fought to hard to bring freedom to.