With only five minutes left of an outstanding game at Carisbrook, the impressive Auckland man, in the team in place of Otago favourite Anton Oliver, dived over the line after fine mauling by the New Zealand pack.
The Springboks remain without a win at Carisbrook, but of more concern to coach Jake White will be the defeat which hands impetus to Graham Henry and his men.
Victory over Australia in Auckland next week will see the trophy stay in New Zealand.
There were five tries in a mesmerising first half, where the All Blacks looked to have opened up a comfortable half-time lead before Enrico Januarie's opportunist effort closed the gap.
Joe Rokocoko scored twice while wing phenomenon Bryan Habana again converted an interception try.
Richie McCaw had called for the All Blacks to tighten up around rucks and mauls ahead of the game, but his words had been forgotten within two minutes of kick off.
The scoring commenced in the second minute, with Percy Montgomery kicking a penalty after French referee Joel Jutge penalised the hosts at the ruck.
However, New Zealand hit back within minutes, putting South Africa behind for the first time in the Tri-Nations.
Springbok first-five Andre Pretorius had his kick charged down by centre Aaron Mauger, and Rokocoko's pace saw him home.
The advantage was lost almost immediately. In the ninth minute, Habana found space on the left after New Zealand lost the ball in the ruck. Montgomery added the extra points.
But after 20 minutes, the Newport full back erred to hand the game back to their hosts.
He failed to grasp Mauger's high ball, under pressure from McCaw. Mealamu charged forward, breaking Montgomery's tackle.
MacDonald, Graham Henry's replacement for Dan Carter, then scored under the posts and converted his own try.
And New Zealand extended their lead to 21-10 five minutes later, continuing a fine start to the game between the world's two top-ranked teams.
Rokocoko exploited weak tackling by the South Africans to bulldoze through like a prop after picking up the loose ball from a ruck five metres out.
MacDonald extended the lead with the conversion, building up an advantage similar to that South Africa held at half-time in Cape Town.
White was handed a fright in the 33rd minute, when Schalk Burger clashed with Pretorius while tackling Tana Umaga.
Burger went off, emerging only in the second half, but Pretorius was removed with a serious-looking leg injury, to be replaced by Jaco van der Westhuizen.
The Springboks' fortunes changed within seconds of half-time. Piri Weepu cleared the ball to MacDonald, but a quick-thinking Januarie charged down his clearance to record five valuable points.
The Springboks, reinforced by Burger, were rampant in the opening exchanges of the second period but their dominance was only rewarded with a 51st-minute Montgomery kick.
MacDonald padded New Zealand's cushion to 24-20 after an hour with another three-pointer, but South Africa's famed perseverance became apparent once more.
Januarie was once again quickest to the ball, intercepting a stray Jerry Collins pass and feeding Jaque Fourie to score under the posts, setting up an easy conversion.
Henry responded by replacing MacDonald with Luke McAlister, his other option for starting first-five, and both props, Carl Hayman and Tony Woodcock.
With the title slipping away, New Zealand stepped up the pace. In the 74th minute, Weepu crossed the line but the video referee ruled correctly that the ball had been lost as he placed the ball down.
And with five minutes to go, Mealamu scored to give New Zealand the victory.
From a lineout, the All Black forwards drove to the line, and the Auckland hooker hung back, split from the maul and plunged over the line.
Blues team-mate McAlister converted to give the All Blacks a decisive advantage.