South Africa witnessed a dramatic collapse after tea, reducing from 226 for three to 262 all out – losing last seven wickets for just 33 runs, a plan termed as ‘simple’ by Pakistan pacer Mohammad Amir.
Vernon Philander then struck back for South Africa, removing Shan Masood and Azhar Ali off successive balls as Pakistan reached 17 for two at stumps.
Amir said there was a meeting in the dressing room during the tea break.
"The first two sessions we didn't bowl well. After that we made a plan to bowl wicket to wicket and control the run rate," said Amir.
Amir and Mohammad Abbas bowled superbly after tea, taking advantage of reverse swing.
Amir had to leave the field with what he said later was an attack of cramp in the left calf but Hasan Ali and Faheem Ashraf sustained the pressure.
Ashraf finished with three for 57, while Amir, Abbas and Hasan took two wickets each.
"This wicket is far better (for batting) than the first two games but I always believe that when you stick to the basics, whether you are a bowler or a batsman, you can get the reward," said Amir.
A risk free innings of 90 by Aiden Markram laid the foundation for some attacking batting by South Africa. But the runs dried up after the interval as South Africa were able to add only 36 runs for the loss of seven wickets in 19.4 overs, hitting only four boundaries.
"It was the best I've moved in a session," Markram said. "It's important to respect the good balls but when there is a ball in your zone you need to be in a frame of mind to put it away."
Markram, who hit 16 boundaries, dismissed in the nineties for the third time in his 15-Test career.
The 24-year-old, who had to pass a fitness test after suffering a badly bruised right thigh while fielding in the second Test, looked set for his fifth Test century until he glanced a ball from Faheem and wicketkeeper Sarfraz Ahmed dived to his left to take a good catch.
"Our total is a bit under par but it did seem to be a bit more difficult to bat on later on," said Markram.
Hashim Amla (41) helped Markram put on 126 for the second wicket after stand-in captain Dean Elgar was caught behind off Mohammad Abbas for five in the second over.
Theunis de Bruyn (49) and debutant Zubayr Hamza (41) both batted brightly in a fourth wicket stand which was worth 72 off 92 balls at tea.
But De Bruyn was out in the third over after tea and Hamza, who scored 38 off 46 balls before tea, could add only three more runs off 22 deliveries before he was caught behind off Amir.
Left to negotiate a tricky 40 minutes before the close, Pakistan lost Shan Masood, their top scorer in the series, for two when a successful review by South Africa showed he had got a faint edge to a ball angled across him.
Azhar Ali (0) received a superb first delivery which seamed way from him and found an edge for wicketkeeper Quinton de Kock to take a second catch.