CAPE TOWN — President Jacob Zuma has survived a no-confidence motion in Parliament on Tuesday, but by a much narrower margin than expected, a stark indication that a long-running corruption scandal threatens his party’s hold on power.
After hours of heated debate, the motion was defeated, with 177 lawmakers voting yes, 198 voting no and nine abstaining.
If Mr. Zuma had lost, he would have had to resign, along with his entire cabinet. It was the fourth no-confidence vote in Parliament that Mr. Zuma has survived, but the first to be conducted by secret ballot.
Opponents had hoped that anonymous voting would embolden disaffected A.N.C. loyalists to defect and vote against Mr. Zuma without fear of reprisal, and it appears that many did so: The A.N.C. controls 249 seats in the 400-member National Assembly; the motion needed 201 votes to pass.
A.N.C. members on Tuesday argued that removing Mr. Zuma would set a destabilizing and dangerous precedent, but they did not defend his tenure in office.
Mr. Zuma’s opponents said the vote was essential to restoring confidence in the government and improving the economy. They repeatedly cited a long-running scandal involving the Guptas, a powerful family that has extensive business holdings and is close to Mr. Zuma.
“I am asking you today to overcome your fears, to show courage when the people of this country need you the most,” said Mmusi Maimane, the leader of South Africa’s main opposition party, the Democratic Alliance, which introduced the no-confidence motion. “I am asking you today to vote for hope — the hope that we can defeat the corruption that oppresses the people.”
Julius Malema, the leader of the left-wing Economic Freedom Fighters, asked members of the A.N.C., to which he once belonged, to distinguish between Mr. Zuma’s interests and their own.
“We are not here today to remove the democratically elected government of the A.N.C., which was voted for by our people in 2014,” he said, referring to the last national election. “Whether we like it or not, we must at all times respect the wish of the people.”
The vote, he said, was “not against the A.N.C.” but against its leader, whom Mr. Malema called “the most corrupt individual in this country.”
Mangosuthu Buthelezi, 88, a veteran of the struggle to topple apartheid and the leader of the Inkatha Freedom Party, said that the “poisoned seed of corruption” had been planted well before South Africa’s transition to democracy, but that misrule by Mr. Zuma had “reached the point that the unthinkable became possible.”
Puleng Mabe, an A.N.C. lawmaker, said that if the motion was enacted, it would amount to a coup d’état. He acknowledged that “the outrage in the public over the levels of real and perceived corruption must be addressed by this Parliament.” But he said the proper way to do that was through independent oversight, not toppling Mr. Zuma and his cabinet.
“The court of public opinion must not be allowed to become the benchmark of decision making,” Mr. Mave said. “This is even more important today, where social media seeks to influence the outcomes, even without subjecting itself to the test of veracity.”
Another A.N.C. lawmaker, Dorries Eunice Dlakude, said the secret ballot risked even greater interference in politics from powerful interests. She was one of several lawmakers who questioned the decision by the speaker of Parliament, Baleka Mbete, to allow a secret ballot. Under the Constitution, Ms. Mbete would replace Mr. Zuma if the motion passed and he resigned.
“We are not sellouts,” Ms. Dlakude said.
Pieter Groenewald, the leader of the Freedom Front Plus, a party of white Afrikaners that allied itself with the Democratic Alliance after municipal elections last year that delivered a major blow to the A.N.C.’s control of Johannesburg and several other cities, argued that the motion was in the A.N.C.’s interest.
“What we have in South Africa is a president who is constantly doing blame shifting,” Mr. Groenewald said. “It’s always someone else’s fault.”
He urged members of the A.N.C. to abstain rather than vote against the resolution, warning that if they kept Mr. Zuma, voters would blame them, and not just the president.
Ralph Mathekga, a political analyst, said he was struck by the sober tone of the A.N.C. lawmakers.
“The A.N.C. I saw in today’s debate was very different from the arrogant party we normally see in Parliament,” Mr. Mathekga said in a phone interview. “ It was a complete shift in tone from previous motions of no confidence where they have defended Zuma.”