The match, the first major game of rugby to be played in Soweto, was staged at the same venue that hosted last month's soccer World Cup final. A record crowd of over 90 000 were in attendance.
The All Blacks trailed 22-17 as they launched wave after wave of attacks and McCaw forced his way over in the left corner, the try only being awarded after a lengthy review by the television match official Shaun Veldsman.
Flyhalf Dan Carter, who only succeeded with five of his nine kicks at goal, hacked the touchline conversion wide to leave the scores at 22-22.
But the All Blacks then won the kick-off and powerful centre Ma'a Nonu muscled his way through midfield before firing out a long pass for replacement wing Dagg to run over the line unopposed, Carter kicking the conversion.
The visitors had played most of the rugby, dominating possession and constantly probing with their ball-in-hand approach.
But the Springboks produced a passionate defensive performance, were far more accurate at the breakdowns and remained in front thanks to the faultless goal-kicking of flyhalf Morne Steyn, who scored five penalties and a conversion.
New Zealand now have 23 points and have won the Tri-Nations for the 10th time in 15 years with a game to spare. Defending champions South Africa have now lost four matches in a row.
The Springboks showed in the first half that they can still use the type of rugby that led them to glory last year as they pulled away for a 16-9 lead after 31 minutes.
Rookie scrumhalf Francois Hougaard's excellent kicking and fielding of returns from the All Blacks set up two early penalties for Steyn after Carter had opened the scoring for New Zealand in the fifth minute with a penalty.
The 22-year-old, making his first test start, also sparked several attacks and earned another penalty in the 31st minute when wing Joe Rokocoko was ruled to have taken him out off the ball as he chased his own chip-kick.
Juan Smith, who added tremendous steel to the Springbok defence, stole a New Zealand lineout in the 24th minute, leading to fellow flank Schalk Burger forcing his way over for the home side's only try.
Carter punished ruck mistakes by centre Juan de Jongh and lock Victor Matfield before the All Blacks tidied up loose ball in their own half, recycled possession and engineered a large overlap on the right.
Prop Tony Woodcock took the final pass and sauntered over for the try, allowing New Zealand to close to 14-16 at the break.
It was the Springboks who dominated the early exchanges in the second half, Steyn kicking penalties in the 42nd and 61st minutes to extend the lead to 22-14 in front of a delirious crowd but New Zealand's late flourish saw them home.
It was an unfortunate ending for South African captain John Smit who was celebrating his 100th test appearance.
Scorers:South Africa - Try: Schalk Burger. Conversion: Morne Steyn. Penalties: Steyn (5).
New Zealand - Tries: Tony Woodcock, Richie McCaw, Israel Dagg. Conversion: Dan Carter. Penalties: Carter (4).
Springboks – 15 Gio Aplon, 14 JP Pietersen, 13 Juan
de Jongh, 12 Jean de Villiers 11 Bryan Habana, 10 Morné Steyn, 9
François Hougaard, 8 Pierre Spies, 7 Juan Smith, 6 Schalk Burger, 5
Victor Matfield, 4 Flip van der Merwe, 3 Jannie du Plessis, 2 John Smit
(c), 1 Gurthrö Steenkamp.
Subs: 16 Chiliboy Ralepelle, 17 CJ van der Linde, 18 Danie Rossouw, 19
Francois Louw, 20 Ricky Januarie, 21 Butch James, 22 Wynand Olivier.
All Blacks – 15 Mils Muliaina, 14 Cory Jane, 13
Conrad Smith, 12 Ma’a Nonu, 11 Joe Rokocoko, 10 Daniel Carter, 9 Jimmy
Cowan, 8 Kieran Read, 7 Richie McCaw (c), 6 Jerome Kaino, 5 Tom
Donnelly, 4 Brad Thorn, 3 Ben Franks, 2 Keven Mealamu, 1 Tony Woodcock.
Subs: 16 Corey Flynn, 17 John Afoa, 18 Samuel Whitelock, 19 Victor Vito, 20 Piri Weepu, 21 Aaron Cruden, 22 Israel Dagg.