Aiden Markram hit a solid half century and Rassie van der Dussen gave him able company to give South Africa hope of an improbable and intriguing win in the second Test in Rawalpindi on Sunday.
Set a daunting 370-run target, South Africa finished the fourth day on 127-1 with Markram on 59 and Dussen unbeaten on 48. The tourists will need another 243 runs to level the series on Monday.Earlier, Pakistan were helped to 298 all out in their second innings by a scintillating maiden hundred by wicketkeeper batsman Mohammad Rizwan who finished on 115 not out.
South Africa had lost opener Dean Elgar to fast bowler Shaheen Shah Afridi for 17 at the total of 33, before Markram and Dussen negated Pakistani spinners on a seemingly unresponsive pitch, having added 94 for the unbroken second wicket stand.
Markram, who did not score off his first 22 balls, changed gears to reach his fifth fifty off 71 balls and has so far hit nine boundaries and two sixes.
Dussen has so far hit eight boundaries.
South Africa can take confidence from the fact that two targets of 300 plus have been chased in the last 20 days with India overhauling 324 against Australia in Brisbane on January 18 and West Indies scoring 395 against Bangladesh at Chattogram on Sunday -- both on the last day.
Pakistan can take heart from the fact that no team has chased more than the 220 scored by Sri Lanka in 2000 in ten Tests in Rawalpindi, and that South Africa have not chased 250-plus since 2014.South Africa's assistant coach Enoch Nkwe hoped his team can cross the line.
"We need to build on this partnership (Markram-Dussen) as we know wickets can fall in cluster like the first Test," said Nkwe. "The pitch is playing well so the guys need to apply themselves to get to the target."
Rizwan said one wicket can open the door for Pakistan.
"Whenever we get one more wicket we are confident that we can catch them," he said. "We need this win and we have spoken positively about it."
It was Rizwan who gave Pakistan a sniff of victory.
He was at his best, putting on a match-turning 97-run partnership for the ninth wicket with number ten batsman Nauman Ali who made 45, frustrating the South Africans who were looking for a series-levelling win.
Rizwan, dropped on four by Dussen off Keshav Maharaj on Friday, punished South Africa and quashed their hopes of a win with 115 not out, spread over 292 minutes and laced with 15 boundaries.
He took a sharp single to reach his hundred, surpassing his previous best of 95 scored against Australia at Brisbane in November 2019.
The 97-run stand is also a new record for the ninth wicket against South Africa, bettering the 80 runs scored between Azhar Mahmood and Shoaib Akhtar at Durban in 1998.
Spinner George Linde, who took 5-64, recorded his first five-wicket haul when he dismissed the last man Shaheen for four. Maharaj finished with 3-118 while Kagiso Rabada had figures of 2-34.
Pakistan, resuming on 129-6, added 88 runs for the loss of Hasan Ali (five) and Yasir Shah (23) in the first session.
Hasan was the first to go when he was trapped leg-before in the sixth over of the day but Yasir helped Rizwan put on 53 for the eighth wicket in a stubborn stand.
Linde, who dropped Yasir off his own bowling when the batsman was on 15, finally had him caught behind by wicketkeeper Quinton de Kock to break the stand.