South Africa's deputy president Cyril Ramaphosa has been leader of the African National Congress, the country's ruling party, in a close-run vote.
Mr Ramaphosa, a 65-year-old union leader who became a businessman and is now one of South Africa's richest people, has vowed to fight rampant corruption and revitalise the economy.
As ANC leader, he is likely to become the country's next president after elections in 2019.
He narrowly beat Nkosazana Dlamini-Zuma, 68, a former cabinet minister and ex-wife of President Jacob Zuma, in Monday's vote.
Ms Dlamini-Zuma, 68, the president's preferred candidate, had campaigned on pledges to tackle the racial inequality that has persisted since the end of white-minority rule.
Mr Zuma's presidency, tainted by graft accusations that he denies, has tarnished the image of 105-year-old liberation movement, and raised the prospect of splits.
Mr Ramaphosa defeated Ms Dlamini-Zuma by 2440 votes to 2261, an ANC spokesperson announced.
The result triggered celebrations among party delegates in Johannesburg and also on the streets of the city.
The rand currency had risen to a nine-month high of 12.5200 earlier, in as the market priced in a Ramaphosa victory. Government bonds also closed firmer before announcement that Ramaphosa had won the race.