South Africa beat New Zealand 28-19 in the second match of the Tri-series rugby tournament in Bloemfontein, South Africa, on Saturday.
The score was 14-3 at halftime.
The All Blacks made a slow start and were camped in their own half for much of the first 40 minutes. South Africa failed to take full advantage of a steady stream of penalties.
However, the All Blacks had closed to within four points before the Boks gained a decisive try in the 72nd-minute.
The two sides meet again in Durban on 1 August.
The result means South Africa reclaimed the International Rugby Board's number one ranking from the All Blacks.
New Zealand won the opening game of the series, beating Australia 22-16 at Eden Park in Auckland last Saturday.
Scorers at Bloemfontein were:
South Africa - Tries: Ruan Pienaar, Jaque Fourie; Penalties: Francois Steyn (2), Pienaar, Morne Steyn (3).
New Zealand - Try: Conrad Smith; Conversion: Stephen Donald; Penalties: Donald (4).