Johannesburg - Pakistan opening bowler Mohammad Amir said a simple plan hatched at tea time was responsible for a dramatic South African collapse on the first day of the third and final Test at the Wanderers Stadium on Friday.
From being in control on 226 for three at tea, South Africa were bowled out for 262.
Vernon Philander then struck back for South Africa, taking two wickets off successive balls as Pakistan reached 17 for two at the close.
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 new ball partner Mohammad Abbas bowled superbly in the first nine overs after tea, gaining reverse swing and seldom bowling a loose delivery.
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 continued to put pressure on the batsmen.
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 polished innings of 90 by Aiden Markram, coupled with some wayward bowling, laid the foundation for some attacking batting by South Africa, who collectively hit 37 fours and a six before tea.
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 more boundaries.
Markram was particularly impressive in scoring 78 off 101 balls as South Africa reached 108 for one at lunch.
"It was the best I've moved in a session," he 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 hit 16 boundaries off 124 balls in an innings marked by crisply-struck drives and firm clips to leg. It was the third time in his 15-Test career that he had been dismissed in the nineties.
Markram, who had to pass a fitness test after suffering a badly bruised right thigh while fielding in the second Test in Cape Town, looked set for his fifth Test century until he glanced a ball from the medium-paced 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 new cap 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.