Prosper Utseya became just the second Zimbabwean to take a hat-trick in a one-day international but South Africa still pulled off a 61-run victory in Friday's tri-series clash.
Utseya sparked a remarkable collapse as he claimed the wickets of Quinton de Kock, Rilee Rossouw and David Miller with consecutive deliveries before finishing with career-best figures of 5-36.
However a last-wicket partnership of 36 between Aaron Phangiso and Imran Tahir carried South Africa to a total of 231, which proved more than enough when Ryan McLaren and Dale Steyn took three wickets apiece to bowl Zimbabwe out for 170 in 38.3 overs.
Quick Single: Utseya reported over suspect action
South Africa had been cruising at 142 without loss in the 25th over after being put in to bat when Utseya turned the innings on its head, with Hashim Amla the first to go as he was stumped for 66 off the offspinner's bowling.
De Kock departed for 76 in Utseya's next over before Rossouw and Miller fell first ball, sparking wild celebrations as the 29-year-old Utseya joined Eddo Brandes on the list of Zimbabweans with an ODI hat-trick.
"At the time I was bowling a lot slower because I knew that I was on top and I had, I think, four guys around the bat," said Utseya.
When JP Duminy was trapped lbw by Utseya in the 31st over of the innings, South Africa had lost 5-13 runs in 39 balls, with Utseya making the most of the considerable turn on offer by taking all five.
Fellow offspinner John Nyumbu got in on the act thereafter, dismissing Faf du Plessis, Ryan McLaren and Dale Steyn, before Phangiso and Tahir carried the Proteas to a more respectable total.
"I wouldn't say I was confident that it was enough because I do think we were 50 or 60 runs short," said Hashim Amla, who captained South Africa in the absence of an ill AB de Villiers.
"But with these sort of totals you have to make it defendable."
Zimbabwe twice threatened to pull off what would have been a memorable upset.
After Tino Mawoyo was run out in the third over, Sikandar Raza Butt and Hamilton Masakadza played a series of adventurous shots against the fast bowlers before Phangiso bowled Masakadza and Tahir removed Raza for 35.
Then Sean Williams and Malcolm Waller looked comfortable as they added 46 for the fifth wicket, only for Steyn to break the partnership when he had Waller caught at deep square-leg off a top edge.
McLaren went on to dismiss Williams for 46 and pick up a couple of lower-order wickets, while Steyn grabbed the wickets of Elton Chigumbura and Brian Vitori.
"Had we scored 300 or 350 and won the game, the intensity in the field wouldn't have been as good," said Amla.
"So in the context of the game, we take a lot of confidence from that."