Centurion: A magnificent spell of fast bowling from Duanne Olivier turned the first Test at Centurion in South Africa's favour but Pakistan still closed Thursday's second day with a chance of going 1-0 up in the series.
Olivier took five for 59 as Pakistan collapsed in their second innings from 100-1 at tea to 190 all out, leaving South Africa needing 149 to win. The Pakistanis, however, believe they have enough runs on the board to take the series opener.
Temba Bavuma, whose 53 was a major contributor to South Africa taking a 42-run lead in the first innings, said there was no sense of complacency in his dressing room.
Masood and Imam-ul-Haq, who made 57, took Pakistan to 100 for one at tea, at which stage the tourists were well-placed to set a challenging target.
Olivier took two wickets in four balls immediately after the interval and went on to complete match figures of 11 for 96 following his six for 37 in the first innings.
Imam was bowled off an inside edge in the first over after tea and Masood quickly found himself running out of partners before he was ninth out after a fighting 120-ball innings which included seven fours.
Kagiso Rabada and Dale Steyn supported Olivier with three and two wickets respectively.
It was the second successive day on which 15 wickets fell.
Bavuma (53) and Quinton de Kock (45) were mainly responsible for South Africa squeezing out a 42-run first innings lead despite good bowling from Mohammad Amir (four for 62) and teenager Shaheen Shah Afridi, who took four for 64.
Imam and Fakhar Zaman wiped out the deficit with a first-wicket stand of 44 and Masood joined Imam in a 57-run second-wicket partnership.
Imam survived a shaky start, which included a chance to first slip Hashim Amla off Steyn when he had 15, to bat with assurance until tea. But he did not add to his score before he was hurried by Olivier and played on to his stumps.
Olivier then claimed the wicket of the experienced Azhar Ali, with the help of a diving Rabada at midwicket after a mistimed pull shot.
The rest of the batting crumbled, with Steyn having Asad Shafiq caught behind and Rabada ripping out the next three batsmen cheaply.