Needing 191 to win, Pakistan were 78 for three at lunch on Monday, with Younis Khan and Mohammad Yousuf, two of their most experienced batsmen, at the crease.
South African hopes were raised when Pakistan were three down with only 48 runs scored but Younis (20 not out) and Yousuf (12 not out) added 30 runs without being separated.
Pakistan made a brisk start to the day with Andre Nel conceding 21 runs in three overs. But a switch of ends for Makhaya Ntini, who took over from Nel, and the introduction of the accurate Shaun Pollock brought a dramatic change.
With his fourth ball from the northern Duck Pond end Ntini dismissed the left-handed Imran Farhat whose flying edge from a slashed shot was well caught above his head by Jacques Kallis at second slip.
Two overs later new batsman Yasir Hameed pushed Ntini into the covers and went for a risky single. Nel ran in from mid-off, picked up and hit the stumps at the bowler's end for Hameed to be run out.
Mohammad Hafeez, who had started the day confidently but was tied down by Pollock, was third out for 32 when he played across the line against Pollock and was given out leg before by umpire Peter Parker, although replays indicated the ball would have just missed leg stump.
Yousuf, playing in his first Test of of the year after setting a Test run-scoring record in 2006, survived a good over from Ntini in which he was twice beaten outside the off stump as he and Younis set about building a partnership.
There was nearly a second run-out three overs before the interval when Yousuf took a quick single to cover and Younis Khan narrowly beat Ashwell Prince's underhand flick on to the stumps.
South Africa lead the three-match series 1-0.
South Africa 124 and 331 Vs Pakistan 265 and 78 for 3 (at lunch)