Pakistan off-spinner Saeed Ajmal ripped through South Africa's batting to leave them reeling on 139 for five at the end of a controversial second day in the second Test at Newlands on Friday.
Ajmal grabbed five for 41 but his brilliant first-innings performance was almost overshadowed by three incidents involving umpire Steve Davis.
South Africa trail by 199 runs having earlier in the day bowled Pakistan out for 338, Vernon Philander picking up five for 59.
The most heated debate occurred after Jacques Kallis was given out lbw for two off Ajmal by third umpire Billy Bowden.
Davis had lifted his finger for what seemed to be a catch off bat and pad and the unhappy Kallis decided to opt for a television review.
Hot-spot showed no edge but the replay revealed the ball would have gone on to clip the outside of leg stump and he was given out lbw.
Kallis argued that he should not be given out as the original bat-pad decision was wrong. However, after lengthy talks between Davis and Bowden, the South African had to walk back to the pavilion.
Neither team nor match referee Jeff Crowe would comment on the matter at the close of play although Pakistan coach Dav Whatmore confirmed his side had appealed for bat-pad only, casting more doubt on the validity of the dismissal.
Ajmal bowled non-stop for 25 overs from just before tea to hand the initiative to Pakistan.
DRYER WICKET
"Ajmal has been able to get purchase on the wicket which is dryer than it has been in the past," South Africa's assistant coach Russell Domingo told a news conference.
"Maybe we could have played more positively against him but the history of Newlands shows the third innings is the trickiest to bat in. If we can get to within 80 or 90 of them in this innings and put them under pressure, hopefully we can chase 250 or so."
Captain Graeme Smith was Ajmal's first victim, trapped lbw for 19 while attempting a sweep. Davis originally said it was not out but the visitors asked for a review and it showed the ball would have hit the stumps.
Azhar Ali then took an excellent one-handed catch at short leg to dismiss Alviro Petersen for 17, Ajmal finding an inside edge that deflected off the pads.
Hashim Amla (25) was then struck on the pads playing back to Ajmal. Once again Davis gave it not out but the lbw shout was overturned on review.
Faf du Plessis took more than two hours to make 28 before his long vigil was ended when he was caught at slip by Younus Khan off Ajmal.
AB de Villiers (24) and Dean Elgar (11) were the unbeaten batsmen when stumps were drawn.
"The conditions here are totally different to the first Test {at the Wanderers)," said Whatmore, referring to his team's 211-run defeat.
"In that match the home side were never under any pressure. This wicket will get harder to bat on so we are happy with our position."
Earlier, Philander registered his ninth five-wicket haul in Tests to bowl Pakistan out on the stroke of lunch.
Philander removed Asad Shafiq for 111 with his first ball of the day before claiming the scalps of Sarfraz Ahmed (13) and Umar Gul (0).
Tanvir Ahmed (44) and Ajmal (21 not out) put on 64 for the ninth wicket until the former fell to Robin Peterson.
Off-spinner Peterson also accounted for the final wicket of Mohammed Irfan (6).
The third and final match of the series is at Centurion.