South Africa were eyeing victory over New Zealand at stumps on day four of the second Test in Christchurch on Monday.
New Zealand, set an imposing record target of 426, were 94-4 with Devon Conway on 60 and Tom Blundell on one.
The Proteas had declared their second innings at 354-9 with Kyle Verreynne 136* – his maiden Test century.
The existing record for the highest-successful fourth innings is 418 by the West Indies against Australia 19 years ago and New Zealand started as if they thought it was within reach.
Tom Latham scampered for a cheeky single off the first ball to show intent but Kagiso Rabada had other ideas.
Following his five-wicket haul in the first innings, and a rollicking 47 with the bat, he removed Will Young for nought with his third ball.
At the start of his second over he dismissed Latham for one and New Zealand were 6-2.
It ended a disappointing Test for the New Zealand openers who managed only four runs between them across the two innings.
Left-arm spinner Keshav Maharaj, South Africa’s point of difference to New Zealand’s all-pace attack, showed there was turn on the wicket and bowled Henry Nicholls for seven and Daryl Mitchell for 24.
When Proteas captain Dean Elgar elected to bat first – the first captain to win the toss at Hagley Oval and not bowl – he said he wanted his batsmen to “front up” after innings of 95 and 111 in their first Test thrashing.
Sarel Erwee obliged with a century in the first innings and it was Verreynne’s turn in the second.
The 24-year-old, with a best score of 30 from his previous five Tests, anchored South Africa’s second-innings revival when they were on 91-5.
He shared in 78-run partnerships with Wiaan Mulder and Rabada before adding a further 32 with Lutho Sipamla until the declaration.
There was nothing reckless about his approach but he punished anything that was loose.
His 50 came from a single when he nudged Kyle Jamieson to fine leg and the 100 was from a boundary when he whipped Matt Henry in the same direction – one of 16 fours along with one six in his 299-minute stay in the middle.
Mulder reached 35 before he edged a Jamieson delivery and was caught one-handed by wicketkeeper Tom Blundell diving to his right.
Marco Jansen made nine before he swung Colin de Grandhomme to deep midwicket where he was caught one-handed by Young as he rolled over to avoid hitting the boundary marker.
Rabada went on the rampage smacking four sixes and four fours to reach 47 off 34 deliveries before he was caught in the deep attempting to reach his fifty.
Maharaj added four in a brief stay in the middle and Sipamla was 10* after surviving a barrage of short balls, including one that struck him on the helmet.
© Agence France-Presse