Pakistan's world-record run of 11 straight Twenty20 series victories came to an end on Sunday as South Africa won by seven runs at the Wanderers.
South Africa defended its total of 188-3 after two thrilling final overs, when four Pakistan wickets fell and the tourists ended on 181-7.
It gave South Africa a winning 2-0 lead in the three-match series and saw Pakistan slip to defeat in a bilateral T20 series for the first time in three years.
Chris Morris took two wickets for South Africa in the penultimate over — both bowled — and Andile Phehlukwayo added two more in the last over. The Proteas held firm after an earlier assault on their total by Babar Azam, who hammered 90 off 58 balls. He fell at the start of the 17th over in the game's pivotal moment.
Stand-in captain David Miller led South Africa to victory — while Faf du Plessis was rested — and did his job in style, smashing 65 off 29 balls with five sixes to top score for his team.