JOHANNESBURG — Cyril Ramaphosa, elected leader of South Africa's ruling African National Congress in a tight race on Monday, now faces the daunting task of uniting a starkly divided party and reviving the tarnished reputation of Nelson Mandela's liberation movement.

The 65-year-old Ramaphosa, the country's current deputy president, beat former African Union commission chairwoman Nkosazana Dlamini-Zuma by a margin of less than 200 votes. As the head of the ANC, Ramaphosa will be the party's candidate for president in 2019 elections, which he is widely expected to win.

Ramaphosa has had an extraordinary career both inside and outside of South Africa's political arena. He has moved from being a prominent anti-apartheid activist and one of the chief negotiators who helped bring an end to white minority rule to becoming one of the wealthiest businessmen in South Africa.

In the run-up to this contest, he styled himself as a reformer who will steer South Africa away from the corruption scandals that have hurt the economy and spooked investors.

"Clearly, Ramaphosa has been the darling of the business community," said Daniel Silke, an independent political analyst. As the party's new leader, he said, Ramaphosa will be seen as attempting to "revive prudent policy-making in South Africa" and "stabilize the creaky ship of the South African economy."

That is no small task. South Africa's economy dipped into recession this year, rebounding to 2.5 percent growth in the second quarter. Unemployment is rampant, hovering close to 30 percent, and the country is rated one of the most unequal societies in the world, where the top 10 percent of earners received 66 percent of the national income, according to the 2018 World Inequality Report.

Ramaphosa also inherits a party that has been riven by corruption scandals during President Jacob Zuma's tenure, cutting into the organization's clout among South African voters and creating stark rifts within Mandela's liberation movement.

The ANC, which marked its 105th anniversary this year, fought to end apartheid and has dominated the political landscape since then. But it has been paralyzed by internal fighting and is losing support among voters who are frustrated that it has failed to deliver on the promise of a post-apartheid government. In recent local government elections, the ANC lost control of Johannesburg, South Africa's largest city, and Pretoria, the capital.

Given the narrow margin of his win, Ramaphosa will have to work hard to unite his supporters and the backers of Dlamini-Zuma, who is the ex-wife of outgoing ANC leader Zuma, if the party is to rally and regain ground in the upcoming national elections in 2019.

Though Zuma's term as ANC leader is now over, his term as South Africa's head of state ends with the 2019 vote. It is not clear if Ramaphosa, as the ANC's new leader, will call on Zuma to resign as the country's president sooner, which the party has the authority to do.

Some observers said that is the move he's likely to make in order to put the party in the best electoral position in two years' time. "There's a shared consensus that (Zuma) is a liability," says Mcebisi Ndletyana, a politics professor at University of Johannesburg.

Though Ramaphosa has been part of Zuma's administration, he has managed to steer clear of the corruption allegations that have dogged some of his colleagues and create enough distance between himself and the besmirched Zuma to not be perceived as part of the problem.

Ramaphosa's win "will be a confidence bounce," says William Gumede, executive chairman of Democracy Works Foundation. "Not just among markets, but among ordinary people."