South Africa’s President Cyril Ramaphosa, testifying at a graft inquiry on Wednesday, said he chose to “remain but resist” rather than resign as deputy president when allegations of widespread corruption surfaced under his predecessor Jacob Zuma.

Ramaphosa, Zuma’s number two from May 2014 to February 2018, has made the fight against corruption a pillar of his presidency, though opposition parties have criticised him for not doing enough to stop the rot during his time as deputy.

Appearing for the second time at an inquiry probing allegations of graft during Zuma’s nine years in power, Ramaphosa said the first option available to him was to resign as deputy president.

While this would have earned him praise from many quarters, he said, it would have “significantly impaired” his ability to end corruption.

He said he ultimately opted to “remain but to resist, hoping that we can turn things around”.

Ramaphosa defeated Zuma’s ex-wife to win the leadership position in the ruling African National Congress (ANC) in 2017 then helped engineer Zuma’s ouster as president.

“With the benefit of hindsight, I am certain that this was the necessary and correct course of action,” he said.

The inquiry, headed by acting Chief Justice Raymond Zondo, is looking into allegations including that Zuma allowed businessmen close to him – brothers Atul, Ajay and Rajesh Gupta – to influence policy and win lucrative government contracts.

The Gupta brothers have repeatedly denied corruption accusations and are now believed to be living in Dubai.

Zuma has denied corruption was prevalent under his administration. He claims the inquiry is politically motivated and has refused to fully cooperate with it.

His imprisonment last month for ignoring a court order to testify before the Zondo commission ignited some of the worst violence in post-apartheid South Africa.

Zuma, who is serving a 15-month sentence, was admitted to hospital last week, forcing the postponement of a separate corruption trial.

Widely referred to domestically as “state capture”, the influence of the Gupta’s extended network only became known through investigative journalists and whistleblowers at state-owned companies, including power utility Eskom and freight logistics firm Transnet.

Reporting by Wendell Roelf; Editing by Joe Bavier and Angus MacSwan