IN THE twilight of his unpopular presidency, Jacob Zuma has to vet his crowds carefully. Almost wherever he speaks, he risks a clamour of boos and jeers, many from members of his own party, the African National Congress (ANC). A rally organised by the country’s main trade union federation, which is formally allied with the ANC, should have been a perfect opportunity for him to drone on about the party’s achievements since ending white-minority rule in 1994. But he never got the chance to speak; union members shouted him down. Two of his closest supporters were also heckled at May Day rallies in different cities on the same day. Unionised workers, who in past elections made up most of the activists going door-to-door to canvas for the ANC, are turning against a tainted president, and against a party that excuses his many scandals.

Mr Zuma’s second and final term of office still has two years to run. Yet the race to succeed him is already on. A lot rests on this transition. It could determine whether the country’s democratic institutions are revived, or whether South Africa descends further into a swamp of corruption and stagnation. “They are demanding bribes to get anything done,” laments one businessman, adding that it was not nearly as bad under previous ANC presidents.

Many people assume that the ANC will win a majority of the national vote in 2019 and that the party leader will therefore be the next president. That party leader will be picked at a congress in December. Mr Zuma hopes to anoint a successor who will shield him from the 783 charges of fraud, corruption and racketeering he faces, which predate his presidency. He is backing his ex-wife, Nkosazana Dlamini-Zuma, a former head of the African Union.

Her main opponent is Cyril Ramaphosa, Mr Zuma’s deputy and a former trade-union boss turned tycoon (the two are pictured either side of Mr Zuma). Mr Ramaphosa is capable and rails against corruption. He has backed a call by Thuli Madonsela, a former public protector, for a judicial inquiry into allegations that Mr Zuma’s rich friends have unduly influenced cabinet appointments and state contracts. Pravin Gordhan, a popular finance minister fired by Mr Zuma, has spoken in favour of Mr Ramaphosa. So too have both of the ANC’s allies, the South African Communist Party and the Congress of South African Trade Unions.

That said, Mr Ramaphosa may not win over enough delegates at the party congress. Many have benefited from the looting of state resources that has proliferated during Mr Zuma’s presidency. Mr Ramaphosa has complained about car boots full of cash being used to buy support. A survey by Rand Merchant Bank (RMB) predicts that Ms Dlamini-Zuma will be the next leader of the ANC.

However, it is not only ANC grandees who will vote. So, in the general election, will ordinary South Africans. Some party members fear that in 2019, for the first time, Africa’s oldest liberation movement will fail to win a majority. The party, which won 62% of the vote in 2014, has lost its lustre under Mr Zuma.

Last year it lost power in several of South Africa’s biggest cities. Municipal IQ, a research firm that has analysed the results of local elections in 2011 and 2016, when support for the ANC slumped from 62% to 54%, reckons it could fall below 50% nationally in 2019. RMB’s survey found a “meaningful probability” that the ANC would lose power.

Many in the ANC are nervous. Discussion documents released ahead of a party policy conference that will be held from late June fret about “internal squabbles, money politics, corruption and poor performance in government”, and even “the hollowing out of the capacity of the democratic state”. Zweli Mkhize, the ANC’s treasurer, accepts that the ANC “needs to put its house in order”. However Mr Mkhize, like many other senior figures in the ANC, is unwilling to criticise Mr Zuma openly.

He’s still the boss

This deference is partly due to tradition—during the ANC’s many years in exile, internal dissent was stifled—but also because potential rebels are afraid. Mr Zuma wields immense formal powers. As president, he can sack cabinet ministers. And Mr Zuma remains the boss of the ANC, which can kick MPs out of parliament by expelling them from the party if they break ranks on a big vote.

However, a case before the Constitutional Court may weaken Mr Zuma’s hold. Opposition parties have asked the court to allow MPs to cast secret votes in a motion of no-confidence. Mr Zuma has already survived four no-confidence votes and two motions for impeachment because of his iron grip on the party. But secrecy might make ANC MPs braver. And only a quarter of them would have to side with the opposition to kick Mr Zuma out.

However, even if Mr Zuma and his cronies are on their way out, they can still do enormous harm. Take the case of Brian Molefe, who just a few months ago was forced to resign as head of Eskom, the state-owned electricity monopoly, after the public protector found he had a “cosy relationship” with pals of the president who had won big contracts from the utility. This week he was reappointed to the post to push through Mr Zuma’s plan to spend as much as 1trn rand ($76bn) on Russian nuclear power plants that will not help at all with South Africa’s immediate energy needs. “The ANC is simply incapable of reforming itself,” says Mzukisi Qobo of the University of Johannesburg, a co-author of “The Fall of the ANC: What Next?” “We are in for a rough ride.”