Pakistan 272 and 298 (Rizwan 115*, Nauman 45, Linde 5-64, Maharaj 3-118) lead South Africa 201 by 369 runs
Mohammad Rizwan's first Test century allowed Pakistan to set South Africa a target of 370 to level the series but the hosts will fancy their chances of victory even though the surface has settled. Unlike on the first three days, when the ball kept low and reverse swing played a role, scoring was free-flowing and Pakistan made the most of the conditions.
Their last five pairs put on 222 runs, including 53 between Rizwan and Yasir Shah, and 97 between Rizwan and Nauman Ali, and continued the trend of making valuable lower-order contributions from the home side. At the same time, their stubborn resistance told the story of the problems South Africa have encountered in dismissing the tail throughout the series. In Karachi, Pakistan's last five stands were worth 202 in the first innings, setting up a lead that laid the foundation for the win.
Despite that, the South African attack took pride from how they controlled the run rate. Even that failed them in the post-lunch session in Rawalpindi. South Africa conceded 81 runs in 17 overs, at a rate of 4.76 as Rizwan and Nauman took advantage of a weary attack. But, there was some consolation for South Africa's bowlers. George Linde, bowling with heavy strapping around his lacerated left little finger, took his first five-for, joining Anrich Nortje and Hasan Ali as the bowlers who have prospered on this pitch.
South Africa's spinners fared better than their seamers overall with Keshav Maharaj taking the first wicket of the morning in the sixth over when he hit Hasan Ali on the front pad with a ball that would have gone on to clip leg stump. Maharaj would have added a second scalp in his next over but Shah missed the cut shot and got an edge but the ball popped out of Quinton de Kock's hands. Shah was on 10 at the time and his partnership with Rizwan worth 12. The stand grew more than four times that by the time Shah was deceived by a change of pace from Linde and he chased a wide ball to be caught behind for 23.
In between that, South Africa thought they had snared Rizwan when he missed a cut shot off Linde and de Kock reviewed for a catch. UltraEdge, however, showed the ball did not make any contact with the bat. Rizwan was on 43 at the time and went on to bring up fifty off 113 balls with a cut, a shot that served him well throughout the morning.
Rizwan was undeterred by the threat of Nortje's short ball and was strong on the back foot and the pull. He dispatched Kagiso Rabada, who only bowled seven overs on the fourth day, in similarly dismissive fashion, before and after he reached his hundred which came with a single off Linde to cover point.
Nauman could have joined Rizwan with a maiden milestone and batted well to get to 45 before he toe-ended a pull off Rabada to Dean Elgar at midwicket. Pakistan's innings lasted another 19 balls after that before Linde bowled Shaheen Shah Afridi.
Pakistan's total means South Africa will need to pull off the highest successful chase by a visiting team in Pakistan, beating Sri Lanka's 220 at the same venue 21 years ago, and would need to successfully chase a score over 200 for the first time in almost a decade. The last time South Africa managed that was in 2011, against Australia in Cape Town.
Firdose Moonda is ESPNcricinfo's South Africa correspondent