A six from Ryan McLaren off the final delivery and a rapid 116 by Graeme Smith helped South Africa to a thrilling one-wicket victory over New Zealand in the third one-day international on Friday.
The Proteas, who came into the game having already lost the three-match series 2-0, had been set a target of 261 after half-centuries from Grant Elliott (54), Colin Munro (57) and James Franklin (53 not out) had steered New Zealand to 260 for nine in their 50 overs.
Man-of-the-match Smith's knock seemed to have put the home side on course for victory but a lower-order collapse meant they required three off the final delivery with just one wicket in hand.
However, a six over fine leg from all-rounder McLaren (25 not out) gave South Africa their first victory of the series and ensured they avoided a whitewash.
New Zealand had already claimed their first ODI series on South African soil but still went wholeheartedly for the final victory as they won the toss and elected to bat.
They made a slow start as a fine opening spell from left-arm seamer Lonwabo Tsotsobe (10-2-45-4) helped restrict them to 68 for four in the 22nd over.
The half-centuries from Elliott and Munro saw the Black Caps put on successive fifty partnerships and by the time both men had been dismissed, the visitors had recovered to 196 for six after 43 overs.
Despite a late flurry of wickets, Franklin came in and played with freedom. His undefeated innings was rounded off in style as he reached his fourth ODI fifty with a six in the final over from Rory Kleinveldt.
The South African reply made a brisk start as the left-handed opening duo of Smith and Quinton de Kock (31) took the score to 54 without loss after the first powerplay.
Franklin (6-0-38-2) made the breakthrough in the 16th over when he bowled de Kock but at 83 for one, the openers had laid a good platform for the home side.
Smith looked undeterred by the loss of his partner and later reached the fifty-mark in the 20th over.
He and Colin Ingram (25) then took the score to 122 by the end of the 26th over and it prompted the pair to take the batting powerplay.
The decision merely succeeded in yielding instant dividends for New Zealand though as Nathan McCullum (10-1-35-1) had Ingram caught at mid-wicket with the next delivery.
South Africa then showed signs of stuttering as the dismissals of captain Faf du Plessis (19) and Farhaan Behardien (4) reduced them to 174 for four.
Smith was not to be denied though and brought up his 10th ODI century with consecutive boundaries off Kane Williamson (8-0-40-2) in the 41st over.
But the dismissal of David Miller (15) in the following over triggered a collapse including the wicket of Smith, meaning South Africa needed eight off the final over with just two wickets in hand.
The Proteas required three off the final two deliveries and when Dale Steyn (4) was caught on the boundary, it was left to McLaren to get the hosts over the line.
The left-hander duly obliged as he dispatched the final delivery from Franklin (6-0-38-2) over fine leg for a dramatic six to the delight of the ecstatic crowd.
Scorecard
New Zealand
M.Guptill c Ingram b Tsotsobe 5
BJ Watling c du Plessis b McLaren 20
K.Williamson c de Kock b Tsotsobe 6
G.Elliott c Steyn b Tsotsobe 54
B.McCullum c Steyn b McLaren 13
C.Munro c de Kock b Tsotsobe 57
J.Franklin not out 53
N.McCullum c de Kock b McLaren 2
J.Neesham lbw b McLaren 13
K.Mills run out (du Plessis) 7
M.McClenaghan not out 2
Extras: (b-1 lb-10 w-17) 28
Total: (for nine wickets, 50 overs) 260
Fall of wickets: 1-15, 2-27, 3-46, 4-68, 5-129, 6-196, 7-199, 8-216, 9-234.
Bowling: Steyn 10-1-56-0 (w6), Tsotsobe 10-2-45-4, Kleinveldt 10-1-44-0 (w4), Phangiso 8-0-43-0 (w1), McLaren
10-0-52-4 (w2), Behardien 2-0-9-0.
South Africa
Q.de Kock b Franklin 31
G.Smith c Watling b Williamson 116
C.Ingram c Guptill b N.McCullum 25
F.du Plessis c Guptill b Mills 19
F.Behardien c & b Williamson 4
D.Miller b Mills 15
R.McLaren not out 25
R.Kleinveldt b McClenaghan 6
A.Phangiso c B.McCullum b McClenaghan 9
D.Steyn c Elliott b Franklin 4
L.Tsotsobe not out 0
Extras: (b-4 lb-1 w-5) 10
Total: (for nine wickets, 50 overs) 264
Fall of wickets: 1-83, 2-122, 3-165, 4-174, 5-205, 6-229, 7-237, 8-251, 9-258
Bowling: Mills 10-0-40-2, McClenaghan 10-0-70-2 (w-3), Neesham 3-0-22-0 (w-2), N.McCullum 10-1-35-1, Franklin 6-0-38-2, Elliott
3-0-14-0, Williamson 8-0-40-2.
South Africa won by one wicket
New Zealand won series 2-1
Photograph: Lee Warren/Gallo Images/Getty Images