South African President Jacob Zuma on Tuesday survived a parliamentary vote of no confidence, with enough ANC lawmakers sticking by their leader despite divisions and fierce criticism of his rule.
The motion brought by the opposition needed to secure 201 of the 400 votes in parliament to succeed, but fell short with 177 votes, national assembly Speaker Baleka Mbete announced.
If Zuma had lost, he would have been forced to resign along with his entire cabinet.
Criticism of Zuma from within the African National Congress (ANC) has grown amid multiple corruption scandals and South Africa's mounting economic woes, while the celebrated party of Nelson Mandela has declined sharply at the polls.
But ANC officials and analysts had predicted the president would survive the vote given the party's large parliamentary majority.
"The party will spin this as a win, but it's a weak victory," independent analyst Daniel Silke told AFP, after at least 30 of the 249 ANC lawmakers voted to oust the president.
"There are marked signs of a rebellion within the ANC. It will perpetuate the factional infighting after a relatively close vote. There was a relatively substantial mutiny," Silke said.
The ANC parliamentary party celebrated victory over what it described as an attempted "soft coup".
"It has been the publicly stated intention of the opposition... to sow seeds of chaos in society to ultimately grab power," it said in a statement.
Several opposition parties led thousands of anti-Zuma protesters outside the national assembly before the vote, while supporters of the president held a rival march.
Zuma, who has built up a network of loyalists in the ANC since coming to power in 2009, has survived several previous parliamentary votes but these had been held without secret balloting.
"Today's motion of no confidence result is closer than anyone expected," Mmusi Maimane, leader of the main opposition Democratic Alliance party said, hailing "brave" ANC lawmakers who voted against Zuma.
Zuma, 75, is due to step down as head of the ANC in December, and as president before the 2019 general election -- lessening pressure for his party to trigger imminent change.
The ANC has acknowledged recent criticism of the party, including the impact of a cabinet reshuffle in March when respected finance minister Pravin Gordhan was replaced with a close Zuma ally.
Gordhan's sacking led to a string of downgrades to South Africa's credit rating as well as causing the rand currency to tumble.