President Cyril Ramaphosa delivers his State of the Nation address at Parliament in Cape Town, South Africa,on Friday. (Pool/Reuters)

IN HIS nine years as president, Jacob Zuma inflicted far-reaching damage on South Africa’s political culture and its democratic fabric. He violated the constitution, ignored court orders, allowed massive graft to spread through his government and enabled what critics are calling “state capture” by one powerful business family. While he and his cronies prospered, South Africa’s economy stagnated, with unemployment above 27 percent and schools and health care crumbling.

The good news is that the political system survived — and, in the end, expelled Mr. Zuma. The two-term president was forced to step down Thursday by the threat of a parliamentary vote of no-confidence, and he was succeeded by Cyril Ramaphosa, a stalwart of the ruling African National Congress. South Africa’s liberal institutions ultimately checked the abuse of power, a worthy example on a continent where strongmen such as Congo’s Joseph Kabila and Kenya’s Uhuru Kenyatta have flouted democratic norms.

That Mr. Zuma failed to similarly entrench himself owes something to South African courts, which sanctioned his use of $600,000 in state funds to upgrade his home. Critical media and investigations by civil society groups helped. But the largest factor may have been anxiety within the ANC that it risked losing its dominance over post-apartheid South Africa. With the next presidential election due in 2019, party members worried about a potential upset — particularly given some stunning losses in municipal elections.

Mr. Ramaphosa, a former close associate of Nelson Mandela who became deputy president in 2014, began to speak out about corruption last year. In December he won election as party president, defeating Mr. Zuma’s attempt to install his wife as his successor. Mr. Ramaphosa then skillfully overcame Mr. Zuma’s stiff resistance to resigning, avoiding an outbreak of violence or a split in the party.

The new leader has promised to tackle corruption and has made a promising start, installing new leadership at the graft-plagued state power company. Even as he took office, police raided the home of the Gupta family, accused of using its connection to Mr. Zuma to benefit its extensive commercial interests. Mr. Zuma himself could face prosecution, if the new government decides to pursue it; that will be an important early decision for Mr. Ramaphosa.

Rooting out the corruption now embedded throughout South African government will not be the new president’s only daunting task. He also must face the country’s yawning economic inequality, an enduring legacy of white minority rule. Pressure for populist policies is growing: Under Mr. Zuma, the ANC adopted a proposal to change the constitution so that farmland, much of it still owned by whites, could be forcibly seized and redistributed.

Mr. Ramaphosa, who promised to speed land reform in his first speech as president Friday, must find a way to do that without repeating the disastrous history of neighboring Zimbabwe, which crippled its economy with forced farm confiscations. His performance in seeking to revive South Africa’s economy and better distribute its wealth will do much to determine whether democratic institutions continue to hold.