PRETORIA, South Africa — South African President Jacob Zuma survived a parliamentary vote Tuesday that could have pushed him from office, hanging on to sufficient backing within his African National Congress party amid growing claims of corruption and worries about a stumbling economy.

It was the sixth time that Zuma has ridden out a no-confidence vote since becoming president in 2009. The outcome further reinforced the dual images that have taken shape as he has beaten back challenge after challenge over the years.

To supporters, Zuma is a steady hand and political patriarch needed to keep the country in balance. Among critics, he has been portrayed as a crafty strongman who muzzles internal party dissent and continually manages to choke off the opposition.

Tuesday’s vote marked the first time that Parliament members were allowed to vote anonymously on whether to keep him in power. Still, the outcome was the same as in previous bids to oust him, as the ANC core refused to splinter.

Although Zuma survived, he emerged weakened from the process, as some members of his party voted against him for the first time. His ANC colleagues took to the well of Parliament to defend the party and its legacy fighting apartheid, but practically none expressed confidence in the president.

Zuma’s ANC dominates Parliament with 249 out of 400 seats, and his opponents needed at least 50 party members to defect — something that has never happened before in a party that defeated South Africa’s apartheid system and is known for its loyalty.

In the end, however, more than two dozen ANC members voted against Zuma, making it the closest the opposition has come to forcing him out.

The motion went down 198 to 177, said the Parliament speaker, Baleka Mbete. Nine lawmakers abstained, and the remainder did not vote.

The results of the vote were announced after a full day of debate, voting and ballot counting. Zuma’s term is set to run until elections in 2019.

Outside Parliament, Zuma thanked ANC supporters who had awaited the vote. And he promised electoral victory in 2019.

“We represent the majority of the country,” Zuma declared. He said that would be proved anew in two years “when we win by a big number once again.”

Opposition supporters march Tuesday in Cape Town, South Africa, ahead of Parliament’s vote on President Jacob Zuma’s leadership. (Mike Hutchings/Reuters)

Opposition to Zuma’s rule has been growing amid revelations of corruption and influence peddling. In addition, the economy has faltered and unemployment has remained stubbornly high in a country marked by deep inequalities of wealth.

Zuma had been in tight spots before. In the first no-confidence vote in 2010, Zuma was accused of being unfit for office. Other votes were held over accusations that included suspected illegal improvements to his home, mismanagement of the economy and his decision in 2015 not to arrest the visiting Sudanese president, Omar Hassan al-Bashir, who is wanted by the International Criminal Court.

In a debate before Tuesday’s vote, Zuma’s supporters said his ouster could send the country into a leadership crisis. His critics told fellow lawmakers that it was a moment to take a stand.

“Take our country back,” said Mmusi Maimane, head of the main opposition party, the Democratic Alliance.

Maimane called the choice between keeping and firing Zuma a “choice between good and evil,” drawing boos from ANC members.

Immediately after the vote, ANC Police Minister Fikile Mbalula told a raucous gathering of Zuma supporters outside Parliament: “We will never surrender to Mmusi Maimane. We will never surrender to stooges.”

Mbete, the Parliament speaker, shocked South Africans on Monday when she announced her approval of a secret ballot, which allowed party members to vote against their leader outside the public spotlight.

The no-confidence vote, she said, “constitutes one of the severest political consequences imaginable,” adding that her decision to allow the vote to proceed anonymously was “about putting the resilience of our democratic institution to test.”

In June, South Africa’s Constitutional Court empowered Mbete to decide whether to allow a secret ballot. A small opposition party, the United Democratic Movement, called for the vote.

“Voting in favor of this motion will be tantamount to throwing a nuclear bomb at our country,” Jackson Mthembu, the ANC’s chief whip in Parliament, said before the court’s ruling.

It was the first test of the president since he purged his cabinet in March. Among those fired was Finance Minister Pravin Gordhan, who remains a member of Parliament and had indicated that he intended to vote against Zuma.

The firing of the internationally popular Gordhan had immediate effects on the economy, with ­credit-rating agencies Fitch and S&P Global Ratings downgrading South Africa to junk status. They cited political uncertainty in their reviews of the country’s creditworthiness.

The ANC’s alliance partners, the South African Communist Party and Cosatu, a coalition of trade unions, told Zuma to quit. A group of anti-apartheid veterans also asked the president to resign.

Especially damaging to Zuma has been a string of leaked emails showing his tight relationship with an industrialist family, the Guptas. The family has reportedly handpicked cabinet ministers and officials to fill Zuma’s government.

“What you have is a private family actually setting up the institutions of government such that they’re the ones that make the decisions about how the country is running,” said Cathy Powell, a law professor at the University of Cape Town.