South Africa 145 for 4 (Hendricks 42, van Biljon 42, Afridi 2-18) beat Pakistan 144 for 7 (Rizwan 51, Pretorius 5-17) by six wickets.
Proteas broke a losing streak that stretched back five T20Is to last February and stayed alive in the ongoing series in Pakistan by successfully chasing 145 in foggy conditions in Lahore.
They laid the groundwork for victory after choosing to field for the second successive match and restricting Pakistan to a below-par total, thanks to an outstanding performance by Dwaine Pretorius.
Man-of-the-match Pretorius claimed 5-17 as Pakistan were restricted to 144 for seven in their 20 overs after Heinrich Klaasen had won the toss and asked the home side to bat first.
Pretorius took a wicket at the start and returned to take four in the last quarter of the innings to keep the hosts to a chaseable total. Reeza Hendricks and Pite van Biljon's 77-run third-wicket stand set South Africa up for victory, and David Miller sealed it with 22 balls to spare.
As Pretorius was on the rampage, only Mohammad Rizwan provided any resistance to the landslide as the right-handed opener top-scored with 51 from 41 balls with six fours and a six, following on from his unbeaten 104 in the first T20.
Faheem Ashraf was the only other Pakistan batsman to provide any real impetus to the scoreboard as the allrounder clubbed two fours and two sixes from 12 balls to end unbeaten on 30 at the backend of the innings, which helped the home side reach 144 after looking at not making 130.
After having lost the test series 2-0, the Proteas will be looking to round off their Pakistan tour with a victory in the final match and clinch the T20 series in the final game on Sunday.
PAKISTAN: Mohammad Rizwan (wk), Babar Azam (capt), Haider Ali, Hussain Talat, Iftikhar Ahmed, Khushdil Shah, Faheem Ashraf, Mohammad Nawaz, Usman Qadir, Shaheen Afridi, Haris Rauf
SOUTH AFRICA: Janneman Malan, Reeza Hendricks, JJ Smuts, David Miller, Heinrich Klaasen (capt & wk), Pite van Biljon, Andile Phehlukwayo, Dwaine Pretorius, Glenton Stuurman, Lutho Sipamla, Tabraiz Shamsi.