KARACHI: Spinners Nauman Ali and Yasir Shah shared nine wickets to dismiss South Africa for 245 in the second innings and set up a small target of 88 runs for Pakistan to win the first test.
Nauman, a 34-year-old left-arm spinner making his Test debut, returned 5-35 and Shah took 4-79 to bowl out South Africa a half-hour before lunch on day four.
Pakistan's openers had reduced the target to 66 and went to the break at 22-0.
Imran Butt was not out on 12 and Abid Ali was unbeaten on 10.
Pakistan has been in control since taking a 158-run first-innings lead, when its lower order rallied from 27-4 to reach 378, helped by Fawad Alam's gritty century.
South Africa resumed Friday on 187-4 and things immediately got worse for the tourists when fast bowler Hasan Ali bowled night-watchman Keshav Maharaj with the first delivery of day four.
Captain Quinton de Kock, who fell to a reckless shot in South Africa's first innings of 220, failed for the second time against the spinners.
The tourists were just 34 runs ahead when de Kock offered a regulation catch in Shah's second over to give Abid Ali his third catch in the innings.
Nauman then got into the act by having George Linde (11) caught at leg slip.
Nauman wrapped up the innings by claiming the last three wickets off his successive overs.
Temba Bavuma resisted for nearly two hours to score 40 off 93 balls before he was the last man to get dismissed when he attempted a sweep against Nauman and was adjudged lbw.
South Africa struggled against the spinners on the fourth day pitch, adding just 58 runs for the loss of six wickets as Nauman became the oldest Pakistani spinner to take a five-wicket haul in an innings on Test debut.