Having wrestled the Rugby Championship from their rivals last month, South Africa pinned a scrappy New Zealand back for 20 minutes but, with only three points to show for it, the Springboks were left stunned by two scintillating team tries from wing George Bridge and lock Scott Barrett.
A Pieter Steph du Toit try, moments after a stunning Cheslin Kolbe break, got South Africa right back in the match after halftime. Handre Pollard cut the deficit to four points with a drop goal but penalties from Richie Mo'unga and Beauden Barrett consigned South Africa to their first defeat of 2019.
The All Blacks, who have an 11-day break before their next game against Canada, should go on to top Pool B and hope for an easier quarter-final as a result. South Africa next face Namibia in Toyota City.
"It was the full 80 minutes and right to the end of the test match we had to work [hard]," New Zealand captain Kieran Read said.
"Good fortune sometimes happens and in those two moments we managed to take them and that made the difference in the game."
Read suggested that a greasy ball coming off the Yokohama pitch had made life difficult for the players.
"We had to defend early, but when we did get opportunities we tried to speed up the play a bit but it was pretty tough out there with the conditions."
The Springboks had the physicality to match New Zealand but not the precision, with too many missed tackles, at times aimless kicking and poor hands under the high ball gifting away territory.
After a long-range penalty from Pollard opened the score, he missed a simple opportunity to add another when he struck the post.
New Zealand rallied and produced the sucker-punch that knocked the stuffing out of the Boks as the world champions showed clinical finishing with two tries in just a few minutes.
Mo’unga’s clever cross-kick against the Bok rush defence found wing Sevu Reece in acres of space and when he eluded the tackle of Makazole Mapimpi fullback Beauden Barrett moved into the line and slipped the ball to Bridge who scored.
New Zealand’s ability to gluttonously feed off Bok errors also produced the second try as Pollard spilled a high ball and centre Anton Lienert-Brown’s brilliant break against a retreating defence teed up Scott Barrett for an easy score and a 17-3 halftime lead.
The Boks worked their way back into the contest though and, after a break down the right wing by Kolbe, Du Toit picked the ball up at the base of the ruck and cantered over unopposed.
Pollard added a drop-goal on 59 minutes to narrow the New Zealand lead to four points and it was game on again. But a scrum penalty handed the momentum back to New Zealand as Mo’unga converted and when Beauden Barrett added another with eight minutes remaining New Zealand closed out the victory they just about deserved.
"We didn't start well and they did, handling our kicking game really well," Bok captain Siya Kolisi said. "And a little bit of their physicality as well, I think we took too long to get into the game.
"We stuck to our guns in the second half and we scored first, like we planned, but we couldn't capitalise on our opportunities."