Late tries from Richie McCaw and Israel Dagg ruined John Smit's 100th Test appearance for South Africa as New Zealand clinched the Tri Nations title with victory in Johannesburg.
The world champions, playing in front of more than 90,000 spectators, were in command for most of the game and looked to be closing out their first win of the competition after 17 points from Morne Steyn and Schalk Burger's try saw them head into the closing stages with a five-point lead.
But with two minutes to go, All Black captain McCaw went over in the corner to draw his side level, and even though Daniel Carter missed the conversion, there was enough time for Dagg to cross the line and snatch the win.
It was harsh on the hosts and holders, who looked determined to end their run of three straight defeats with a whole-hearted display in the historic clash at the FNB Stadium, better known as Soccer City.
It was the first time ever that a Test match had been played in the township of Soweto and the biggest crowd at a local rugby game since 1955, when the Springboks played the British and Irish Lions at Ellis Park in front of 95,000, was in attendance.
The Springboks were awarded an early penalty just inside their own half after an infringement from the visitors, with Steyn opting to set up a line-out that eventually came to nothing.
New Zealand responded by claiming the first points of the evening via the boot of Carter - the penalty awarded after a high tackle from JP Pietersen on the right.
As the hosts began to settle more, Steyn drew level and then put his side ahead with a near 50-metre kick.
Carter had a chance to make it 6-6 after 16 minutes, but saw his shot at goal come back of the post, only to redeem himself by slotting over moments later when Steyn was offside.
Then came the opening try after 25 minutes when a quick penalty tap-and-go from Steyn and the momentum of the forwards carried Burger over the line.
The Bulls number 10 made no mistake with the conversion, but again the All Blacks hit back in the form of a Carter penalty - this one from the centre of the halfway line.
Pietersen then did brilliantly in defence when he stole the ball away and sent Juan Smith on a run through the middle, but another infringement from the visitors presented Steyn with the chance to extend the lead - which he easily did with an accurate third penalty.
But the All Blacks came right back into it after 36 minutes when a forward move saw the ball quickly switched from left to right with Ma'a Nonu and Tom Donnelly combining to send Tony Woodcock over for his seventh international try.
Carter, though, missed the chance to level things up when he sent his kick wide.
Play was momentarily held up before the break when referee Nigel Owens was knocked down as Burger and Jimmy Cowan tussled for the ball, but the Welshman resumed duties soon after, blowing his half-time whistle as Peter de Villiers' side went into the break narrowly ahead.
The Springboks had a great chance for a second try straight after the restart when Carter's clearance kick was charged down, but the ball was not recycled quickly enough.
There was another penalty that came out of the move, allowing Steyn to open up a five-point gap.
The pace refused to ease up despite no further points being added over the next 15 minutes, but Carter's dart down the left almost opened up the home defence, who had the ever-present Pietersen in the place to intervene.
Steyn extended the gap to eight after the hour mark, with Carter keeping New Zealand within touching distance when he sent over a penalty of his own.
Seven minutes from time the All Black pivot missed a shot from straight in front and that seemed to end all hope.
But two minutes from time, McCaw collected the ball on the overlap and dived over in the right corner, despite the best efforts of three South African defenders.
There was a tense wait before the television referee gave the New Zealand captain the benefit of the doubt and Dagg then crossed on the left as the hosts pushed forward to seal a memorable win.