A late flurry of sixes from Hasan Ali and Babar Azam helped Pakistan set a target of 321 runs for South Africa in series decider in Centurion Wednesday.
Fakhar Zaman hit a second consecutive ton and his departure led to a famous batting collapse. He made 101 runs off 104 balls and hit three sixes and nine boundaries in the process.
However, captain Babar held one end intact and later along with Hasan, who played first ODI of the series, brutally attacked South African bowlers to help Pakistan reach 320-7.
Both Hasan and Babar mustered 73 runs off 24 balls for seventh wicket partnership. Hasan remained unbeaten for 32 runs off 11 balls that included four sixes and a boundary.
Babar was out on the last ball of the match in try to hit a six that may helped him to reach his 14th ODI ton but fell short of couple of metres from the boundary. He scored 94 runs off 82 balls hitting three sixes and seven boundaries in the process.
Opener Imamul Haq also hit his second fifty of the series as he scored 57 runs off 73 balls.
Earlier, South Africa won the toss and sent Pakistan in to bat in the decisive third and final one-day international at SuperSport Park in Centurion on Wednesday.
The match shaped up as a test of South Africa's reserve strength. They were without five players released to the Indian Premier League, who had earned a total of 371 one-day caps.
It was also announced shortly before the toss that Rassie van der Dussen, one of their most reliable batsmen, had been ruled out because of a quad muscle injury.
South Africa made a total of seven changes, with left-arm wrist spinner Tabraiz Shamsi dropped in the only unforced change. Shamsi was replaced with orthodox left-arm spinner Keshav Maharaj. The seven incoming players have a total of 30 caps.
Pakistan made four changes. Leg-spinner Shadab Khan was ruled out with a toe injury and replaced by new cap Usman Qadir. Batsmen Danish Aziz and Asif Ali were replaced by Mohammad Nawaz and wicketkeeper Sarfraz Ahmed, while fast bowler Hasan Ali came in for Mohammad Hasnain.
South African captain Temba Bavuma said he hoped to take advantage of early overhead conditions which could help swing bowling.
He said the new players were like-for-like replacements. "They are fully aware of what is expected of them," he said.
Teams:
South Africa: Temba Bavuma (capt), Aiden Markram, Janneman Malan, Jon-Jon Smuts, Kyle Verreynne, Heinrich Klaasen (wkt), Andile Phehlukwayo, Keshav Maharaj, Darryn Dupavillon, Beuran Hendricks, Lutho Sipamla.
Pakistan: Babar Azam (capt), Imam-ul-Haq, Fakhar Zaman, Mohammad Rizwan, Sarfraz Ahmed (wkt), Mohammad Nawaz, Faheem Ashraf, Hasan Ali, Shaheen Shah Afridi, Usman Qadir, Haris Rauf.