Pakistan beat South Africa by 28 runs and clinched the series 2-1 at the SuperSport Park in Centurion on Wednesday, after the Proteas failed to reach the 321-run target.
South Africa went gone down but they put up a good fight — as losing four key members to the Indian Premier League (IPL) wasn't ideal for the Proteas.
Aiden Markram and Janneman Malan opened the innings for the home side, while Shaheen Afridi and Hassan Ali shared the new ball for Pakistan.
After the pair had provided the Proteas with a half-century stand, Shaheen struck, producing an edge off of Markram's bat, with the ball safely finding its way into the gloves of Sarfaraz Ahmed.
JJ Smuts contributed 14 before getting bowled by Usman Qadir, with the score at 77-2.
A few overs later came the eventful 23rd over by Mohammad Nawaz. The left-arm spinner first trapped Malan (70) in front of the wickets before bowling out Bavuma (20) in the same over to reduce South Africa to 128-4.
Nawaz struck for a third time in the 28th over, trapping Heinrich Klaasen in front of the wickets with score at 140-5.
Then came a 108-run partnership between Kyle Verreynne and Andile Phehlukwayo that made things interesting and gave South Africa some hope.
But Haris Rauf removed Verreynne (62) in the 44th over as South Africa went six down with 248 on the board.
In the very next over, Phehlukwayo (54) vanished as well, exposing the Proteas tail.
Beuran Hendricks became Rauf's second victim of the day, nicking a wide down the leg side delivery back to Sarfaraz.
Keshav Maharaj's stroke-filled 19 was cut short by Shaheen, who bowled him out.
Shaheen hit the bulls eye again in the next over, taking his third wicket of the match.
Earlier, Pakistan skipper Babar Azam missed out on a ton as his team scored 320-7 in their allotted 50 overs.
Babar was just six runs short of scoring his 14th ODI century but the batsman lost his wicket to a top edge catch at point boundary in the last ball of the innings.
Meanwhile, a 32-run cameo by Hasan Ali helped pace up the visiting team's score in the death overs as he smashed four sixes.
Batting first, Pakistani opener Fakhar Zaman continued his splendid form and scored his sixth ODI hundred before getting dismissed by Keshav Maharaj.
The left-hander, who had also played an heroic knock in the previous match, brought up his century in the 35th over but was soon sent back to pavilion in the next over.
Maharaj was pick of the bowlers as he grabbed three key wickets of Fakhar, Imam and Mohammad Rizwan, who was dismissed after scoring just two runs.
Sarfaraz Ahmed, Faheem Ashraf and Mohammad Nawaz also failed to put on a show as the trio only managed 18 runs among them.
On the other hand, Imam-ul-Haq did well to bring up his ninth ODI half-century before getting caught at long-on in the 22nd over.
The left-hander crossed the 50-run mark twice this series; first being his 70-run knock in the opening ODI at the same venue.
Pakistan were off to a good start in the final ODI as the opening batting-duo enjoyed a 112-run partnership before Maharaj got the Proteas its first breakthrough.
Earlier, the home side were 86 after 16 overs at the loss of no wickets with Fakhar (37*) and Imam (44*) present on crease.
South Africa had opted to field first after winning the toss in the final ODI at SuperSport in Centurion.
The home side decided to play without its six key players; five including Quinton de Kock, David Miller, Kagiso Rabada, Anrich Nortje and Lungi Ngidi, who left the national squad to participate in the Indian Premier League while Rassie van der Dussen has been ruled out due to injury.
Four major changes were made in Pakistan's squad as well with Sarfaraz Ahmed, Mohammad Nawaz, Usman Qadir and Hasan Ali coming in for Danish Aziz, Asif Ali, Shadab Khan and Mohammad Hasnain.
The following are the final teams for both countries:
Pakistan: Imam-ul-Haq, Fakhar Zaman, Babar Azam, Mohammad Rizwan, Sarfaraz Ahmed, Mohammed Nawaz, Faheem Ashraf, Hasan Ali, Shaheen Shah Afridi, Usman Qadir, Haris Rauf.
South Africa: Janneman Malan, Aiden Markram, Jon-Jon Smuts, Temba Bavuma, Kyle Verreynne, Heinrich Klaasen, Andile Phehlukwayo, Keshav Maharaj, Daryn Dupavillon, Beuran Hendricks, Lutho Sipamla