Pakistan coped without captain Sarfraz Ahmed as they took their ODI series with South Africa to a decider after seamer Usman Shinwari helped them to an eight-wicket victory on 'Pink Day' at Johannesburg.
The tourists - skippered by Shoaib Malik with Sarfraz having been suspended for four games by the ICC for making a racist comment directed at South Africa's Andile Phehlukwayo during the second game of the series - skittled the Proteas for 164, with left-armer Shinwari bagging 4-35.
South Africa crumbled from 119-2 once Faf du Plessis (57) and Hashim Amla (59) were dismissed; Shinwari narrowly missing out on a hat-trick after he removed Dale Steyn and Kagiso Rabada for ducks, with Beuran Hendricks' inside-edge preventing him from falling lbw.
Du Plessis' men were looking to stretch their unbeaten streak in the annual Pink ODI - a day on which the players wear a pink kit to raise awareness of breast cancer - to eight matches but crashed to a heavy defeat as Pakistan reached their target in 31.3 overs.
Imam-ul-Haq (71) notched his third fifty-plus score of the series, sharing stands of 70 and 94 with Fakhar Zaman (44) and Babar Azam (41no) respectively, as the tourists made Wednesday's fifth ODI in Cape Town - live on Sky Sports Cricket from 10.55am - a winner-takes-all encounter.
Shoaib's side made a superb start with Shaheen Afridi (2-24) reducing South Africa to 18-2 inside six overs, the seamer pinning Quinton de Kock (0) lbw to sour the batsman's 100th ODI and then having Reeza Hendricks (2) caught down the leg-side by stand-in 'keeper Mohammad Rizwan.
Du Plessis and Amla rebuilt with a stand of 101, during which they recorded their 30th and 37th ODI fifties respectively and Du Plessis lofted leg-spinner Shadab Khan (2-42) beautifully over cover for six.
However, Shadab earned revenge when Du Plessis top-edged him to deep mid-wicket and, when Amla was castled by Imad Wasim, the hosts completely folded, losing their final eight wickets for 45 runs, with Shinwari having the in-form Rassie van der Dussen caught behind for 18.
South Africa struck just twice with the ball, firstly when Imran Tahir had Fakhar caught in the deep, a wicket he celebrated by removing his shoe and 'dialling' fellow spinner Tabraiz Shami, who picked up the call with his boot while standing near the Proteas' dugout at The Wanderers.
Imam edged Phehlukwayo behind attempting a booming drive with just one run required but Rizwan finished proceedings off the next delivery as he carved the bowler to the fence through backward point.
Watch the deciding fifth ODI between South Africa and Pakistan, in Cape Town, live on Sky Sports Cricket from 10.55am on Wednesday.