Babar Azam struck his 13th ODI century as Pakistan narrowly beat the Proteas by three wickets off the final delivery of the match in the first ODI in Centurion on Friday.
Asked to bat first by Pakistan, the Proteas found themselves in trouble early on, slumping to 55-4, following the cheap dismissals of Quinton de Kock (20), Aiden Markram (19), Temba Bavuma (1) and Heinrich Klaasen (1).
Rassie van der Dussen and David Miller steadied the ship and patiently batted South Africa back into the contest with a 116-run partnership.
Miller fell for 50 but Van der Dussen kicked on to reach his maiden ODI century with Andile Phehlukwayo adding a valuable 29 down the order before he departed.
Van der Dussen struck a few more big blows as the Proteas posted 273-6 in their 50 overs with the right-hander finishing unbeaten on 123.
LIVE: Proteas vs Pakistan (1st ODI)
READ: Proteas bat first in Centurion opener
READ: Van der Dussen scores maiden ton, Proteas post 273-6
Kagiso Rabada made a brilliant start with the ball for the Proteas by bowling Fakhar Zaman for only eight.
Azam, though, joined Imam-ul-Haq in the middle and together the pair batted Pakistan into a commanding position with the captain playing some truly spectacular shots.
Both players surpassed their half-centuries and continued to frustrate the South African bowlers as pressure began to build on the hosts.
Azam went on to his 13th ODI ton before Anrich Nortje finally broke the 177-run partnership with the breakthrough of Azam, who departed for 103.
Nortje led the Proteas fightback with the ball and pressured the Pakistan batsmen with a number of short deliveries, which yielded the further wickets of Imam-ul-Haq (70), Danish Aziz (3) and Asif Ali (2).
All of a sudden Pakistan were in a spot of bother themselves at 203-5, but wicketkeeper Mohammad Rizwan, who enjoyed excellent success against the Proteas earlier this year, brought the visitors back into the contest.
Rizwan and Shadab Khan absorbed the pressure and applied themselves with a couple of boundaries. The two batsmen stood firm to bring up a 50-run partnership of their own for the sixth wicket.
Phehlukwayo provided a big glimmer of hope when Rizwan was caught by Rabada for 40. Requiring only three from the final over, the Proteas all-rounder removed Khan, who batted well for his 33.
Phehlukwayo kept South Africa in the contest, and just one run was required from the final ball of the innings. With a tight field set, Phehlukwayo steamed in but pitched it up a bit wide, which Faheem Ashraf put through the covers to get his team over the line.
Proteas: Quinton de Kock (wk), Aiden Markram, Temba Bavuma (c), Rassie van der Dussen, Heinrich Klaasen, David Miller, Andile Phehlukwayo, Kagiso Rabada, Anrich Nortje, Lungi Ngidi, Tabraiz Shamsi
Pakistan: Fakhar Zaman, Imam Ul Haq, Babar Azam (c), Mohammad Rizwan (wk), Danish Aziz, Asif Ali, Shadab Khan, Faheem Ashraf, Shaheen Afridi, Mohammad Hasnain, Harris Rauf.