Faf du Plessis and Reeza Hendricks shared a record partnership as South Africa ended a nine-match Pakistan T20 winning streak in the first international at Newlands on Friday.
South Africa prevailed by six runs in a tense finish after being sent in and making 192 for six.
Pakistan came close, scoring 182 for nine.
"We were two boundaries behind," said Pakistan captain Shoaib Malik.
In the end, it was the fielding of David Miller that made the difference. His two direct-hit run-outs, including the key wicket of Babar Azam, and a South African record four catches, meant that Pakistan kept losing wickets as they chased a challenging target. Miller was named man of the match.
Du Plessis hit 78 off 45 balls and shared a record second wicket stand of 131 off 74 balls with Hendricks, who made 74 off 41 deliveries.
Du Plessis said at the post-match presentation that he would not play in the remaining two matches, citing the need to rest ahead of two Test matches against Sri Lanka, starting on February 13.
"It will be a great opportunity for a new captain," he said but did not reveal who, in an inexperienced team, the new leader would be.
Du Plessis's dismissal in the 16th over sparked a mini-collapse. South Africa lost five wickets while scoring only 35 runs in the last 28 balls of the innings. It was the highest total in a T20 international at Newlands but Hendricks admitted at the innings break that South Africa had "lost our way a bit" after seeming to be on course for a total of around 220.
Left-arm fast bowler Usman Shinwari dismissed Du Plessis and Rassie van der Dussen in the same over and finished with three for 31.
Pakistan made a fast start despite losing Fakhar Zaman in the first over. Babar Azam (38) and Hussain Talat (40) put on 81 off 61 balls for the second wicket. At one stage they were scoring at close to 10 runs an over but the scoring slowed against tight bowling by medium-pacer Andile Phehlukwayo and left-arm spinner Tabraiz Shamsi.
The match turned in South Africa's favour when Talat was caught off Shamsi, to be followed in the next over by Babar's run out, after a superb piece of fielding by Miller.
Malik kept Pakistan in the game, scoring 49 off 31 balls before he was dismissed off the third ball of the final over.
"Overall we played well," said Malik, "but South Africa were good in all three departments.
Du Plessis said he was always confident of winning but admitted: "They are a very composed, experienced T20 team. Being so dominant for a lot of games, obviously they are very confident. They are a very good team. We did some really good things tonight."