South Africa's President Jacob Zuma survived a no-confidence motion against him in parliament on Tuesday by garnering 198 votes to the opposition's 177 votes as African National Congress lawmakers rallied to his support.
There were nine abstentions in the secret ballot.
ANC lawmakers erupted into singing and dancing in parliament even before the speaker of the house announced the result of the vote in favour of the 75-year-old Zuma who has been dogged by allegations of corruption during his eight years in office.
"The motion of no-confidence is ... negative," Baleka Mbete, speaker of the 400-member parliament, said.
The rand fell by 1 percent on the announcement of the outcome.
Zuma, who has held power in Africa's most industrialised economy since 2009 but whose time in office has been marked by allegations of sleaze and influence-peddling, has now survived nine no-confidence votes thanks to loyal backing from lawmakers in his ANC.
Had he lost, he and his entire cabinet would have had to step down.
Mbete had earlier ruled that the vote should - unlike other no-confidence votes Zuma faced - be by secret ballot, a decision the opposition hoped would embolden ANC members who are unhappy with Zuma to vote against him.
Melanie Rice has more from Cape Town.
Zuma has upset investors, in particular by removing finance minister Pravin Gordhan in March. The country's credit rating was downgraded to junk by two of the top three rating agencies, unemployment is at a 14-year high of 27.7 percent and the economy is back in recession.
The party, which has ruled South Africa since the end of apartheid in 1994, is deeply divided and several ANC lawmakers have voiced criticism of the veteran leader.
The ANC, in a statement released shortly after the vote, said that the result was "a resounding defeat of the motion of no confidence in President Zuma and our cabinet" and that "the biggest victor of today's event is our constitutional dispensation".
It went further to accuse opposition parties of "craven opportunism and hypocrisy".
The main opposition party, the Democratic Alliance, said in a statement released shortly after the vote that the result was "closer than anyone had expected".
"The result reveals an ANC that is totally divided against itself. Jacob Zuma has survived, but he has nothing to celebrate tonight. He is mortally wounded and his party is in tatters."
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.
Public support for the ANC, which swept to power under Mandela in the first non-racial elections in 1994, slipped to 55 percent in last year's local polls – its worst-ever result.
A handful of MPs, including Gordhan, have publicly joined calls from anti-apartheid veterans and trade unions for Zuma to resign, as South Africa endures record unemployment and a recession.
Zuma has been engulfed by corruption allegations while in office.
A court last year found him guilty of violating the constitution after he refused to repay taxpayers' money used to refurbish his private rural house.
He has been accused of being in the sway of the Gupta business family, allegedly granting them influence over government appointments, contracts and state-owned businesses.
He is also fighting a court order that could reinstate almost 800 corruption charges against him over a multi-billion dollar arms deal in the 1990s.