Pakistan 169 for 6 (Babar 44, Shamsi 4-25) beat South Africa 164 for 8 (Miller 85*, Mahmood 3-40) by four wickets

Pakistan subjected South Africa to their first T20I series defeat in the subcontinent and fourth successive T20I series loss, leaving them empty-handed from their first tour to the country since 2007. In an entertaining finale at the Gaddafi Stadium, Pakistan relied on Mohammad Rizwan and the lower order to take them home, while Babar Azam enjoyed his best knock of the series after scores of 0 and 5 in the first two matches.

This victory was Pakistan's 100th T20I win, making them the first team to register a century of success in this format.

South Africa have no similar good news to report. They saved one of their worst batting collapses for last and lost seven wickets for 55 runs to slump to 65 for 7 just after the halfway stage of their innings. It was up to David Miller to prop them up and he pulled off one of his most authoritative knocks while ushering the tail to take South Africa to a competitive total.

The side fielding second has found it difficult to control the ball in the wet conditions but South Africa put on a spirited effort when their turn came. However, their frontline seamers were all expensive and untidy, allowing Pakistan to win with eight balls to spare. If anything, South Africa will take heart from the knowledge that their second-string side fought hard in Pakistan, but it won't take away from the pressure building on this outfit. South Africa have only won two out of eight trophies in the Mark Boucher era, dating back to December 2019.

Dream Debut

Zahid Mahmood was called up to the Pakistan squad in place of the injured Shadab Khan and had to wait for the last match for an opportunity but he made the most of it. He started with a short ball that Janneman Malan smashed through long-on but soon recovered to take two wickets, and could have had a third in his opening over to celebrate a dream start to international cricket.

Mahmood's first victim was South Africa's stand-in captain Heinrich Klaasen, who tried to sweep the first ball he faced but didn't account for the extra bounce. He top-edged to Usman Qadir at short fine-leg. With the next ball, Mahmood had Malan trapped in the crease by the topspinner in front of middle stump. It was given not out initially but Mahmood convinced Babar to review with three seconds left on the clock and ball-tracking showed that Malan was out.

Three balls later, Mahmood thought he had Andile Phehlukwayo when a full ball hit him below the knee roll but the review showed it had pitched just outside leg stump. But Phehlukwayo didn't last much longer. He slog-swept the next ball he faced to deep mid-wicket, leaving South Africa 48 for 6.

Mahmood enjoyed more success in his third over when he bowled Dwaine Pretorius with a delivery that turned gently as Pretorius attempted to mow it over midwicket and missed.

Miller Time

David Miller wanted to have an influence on South Africa's performance and he ended up scoring more than half of their runs and sharing in a 58-run ninth-wicket stand with Lutho Sipamla to ensure they set Pakistan a challenging target.

Miller had only faced one ball when South Africa slumped to 48 for 6, in the eighth. Though the situation was dire, it meant he had more than half the innings to bat, giving him time in the middle that he does not usually benefit from. Miller's first boundary came from a sweep shot off Qadir, whom he also swiped through square leg. But he really cashed in on Mahmood's final over, sending him for two sixes over long-on to put South Africa in sight of a hundred.

With only the tail to bat with, Miller waited to get as close to the death as possible before he really took the bowling on. He took two fours off Shaheen Shah Afridi and a monstrous six off Hasan Ali before tearing apart Faheem Ashraf's final over, with four sixes. Miller benefitted from some ordinary captaincy from Babar, who did not let Qadir bowl out, and poor lengths from Faheem, who bowled short throughout the over and then dished up a full toss at the end.

In total, South Africa scored 54 runs off the last four overs, and Miller scored 45 of those. He was leg-side dominant and scored 57 in that area, including five of his seven sixes and four of his five fours. This knock was also Miller's first half-century T20 cricket in almost two years. His last one came 13 innings ago, also against Pakistan, when he scored an unbeaten 65 to set South Africa up for a match-winning total in Johannesburg in March 2019.

Rizwan falls short of record

Rizwan's magical week has ended. After scoring his first Test century last Sunday and his first T20I hundred on Thursday, Rizwan was on track to join Brendon McCullum and Chris Gayle as one of only three players to reel off four fifty-plus scores. He took on South Africa's left-arm spinners, Bjorn Fortuin and Jon-Jon Smuts and pulled, cut and slogged anything short, wide or slow but was undone by Tabraiz Shamsi.

The wristspinner almost bowled him with a delivery that was low on leg stump and squirted past, and could have had him caught behind but Klaasen could not hold on to a tough chance from the bottom edge. Shamsi's next ball was yorker-length, Rizwan tried to sweep and missed and was struck on the boot in front of middle stump. He reviewed, in hope, but ball-tracking showed his leg stump would have been disturbed and he had to go for 42.

Shamsi's star rises

After spending the early part of his career playing second fiddle to Imran Tahir, Shamsi stood up as South Africa's best bowler in the country of Tahir's birth. He collected career-best figures of 4 for 25 in this match to cap off a sterling series in which he turned the ball more than the home spinners and consistently challenged batsmen who can pick and play spin.

After taking a wicket with his first ball and threatening Rizwan twice before getting rid of him, Shamsi bowled Hussain Talat with a straight ball, as Talat played for spin and left off stump exposed, and then had Asif Ali caught at long-on looking for six but failing to get hold of the ball. Shamsi finished the series with six wickets for 61 runs at an economy rate of just over five runs an over.

Firdose Moonda is ESPNcricinfo's South Africa correspondent