JOHANNESBURG (AP) — President Jacob Zuma survived a no-confidence vote Tuesday in the seventh and most serious attempt to unseat him after months of growing anger in South Africa over alleged corruption and a sinking economy. But his African National Congress party, which has ruled since the end of apartheid, continued to fracture.

The latest vote to try to dislodge Zuma was the first held by secret ballot after parliamentary speaker Baleka Mbete made the surprise decision to allow it. Opposition parties hoped it would encourage ANC legislators to vote against Zuma without fear of retaliation.

Instead, ANC members in the chamber began singing shortly before the results were announced, while supporters outside started to dance.

A jubilant Zuma, who would have had to resign with his Cabinet if the motion had succeeded, promised the ANC would win the next election in 2019 "in a big number once again." He dismissed "propaganda" that said his party no longer has the people's support. Then he broke into song.

"We will never endorse or vote in favor of any motion that seeks to cripple our country," the ANC said, calling the vote an attempt to remove the party from power.

Of the 384 votes cast, 177 were in favor of the no-confidence motion and 198 were against, with nine abstentions. The no-confidence motion needed 201 votes to succeed.

Dozens of ANC members ended up supporting the no-confidence motion, as the ruling party holds 249 of the 400 parliament seats, five of them currently vacant. Some party members denounced those who voted against Zuma as sellouts, and chief whip Jackson Mthembu said the party would consider disciplining them.

The main opposition Democratic Alliance party said after the vote that "the majority of the ANC have chosen corruption, looting" over the country's interests. Its no-confidence motion said Zuma had "lost all sense of rationality and sound judgment," harming the country's poorest citizens. More than a quarter of the country's workers are unemployed.

Widespread frustration over Zuma has hurt the ANC, the former liberation movement of Nelson Mandela that has led South Africa since the end of white minority rule and the first all-race elections in 1994. Some longtime party members and anti-apartheid activists have openly called on Zuma to go.

On Tuesday, former President Thabo Mbeki said ANC lawmakers must "recall that they are the representatives of the people," according to a video posted by a Nairobi-based journalist on Twitter.

Many predicted the vote would fail, saying most members of the decades-old party would hesitate to make any major leadership changes initiated by the opposition.

"For me, it's among the biggest reasons for the failure of African liberation movements, this misplaced loyalty to the end for the sake of holding it together," said William Gumede, executive chairman of the Johannesburg-based Democracy Works Foundation.

Demonstrations both for and against the 75-year-old Zuma, who has led South Africa since 2009, took place in front of the parliament building in Cape Town before the vote.

"As you can see, thousands of people have reached the end of their tether in terms of what is happening in our beautiful country, our beautiful, diverse country that we should enjoy but we can't enjoy because millions of our people are without jobs," said one protester, Johnnie Jacobs.

"We have got to get rid of this man before he destroys everything that we have all worked so hard for," said another protester, Anne Shirley.

While Zuma's term continues until elections in 2019, there have been calls from within the ANC for him to quit earlier and allow the party to build up support before the vote. The party is expected to replace Zuma as ANC president at a meeting in December.

The reputation of Zuma, who spent a decade in prison for his anti-apartheid activities and has been popular among some South Africans for his personal warmth and populist policies, has been tarnished by allegations of impropriety.

Last year, the Constitutional Court ruled unanimously that Zuma "failed to uphold" the constitution by not paying back some of the $20 million-plus in state money used to upgrade his rural home. Zuma's ties to the Gupta family, immigrant businessmen accused of trying to manipulate government leaders and state companies for financial gain, also have stirred public anger.

The president's firing of widely respected finance minister Pravin Gordhan in a Cabinet reshuffle in March led two agencies, Fitch and Standard & Poor's, to lower South Africa's credit rating to below investment grade, or junk status.