Cape Town: Off-spinner Saeed Ajmal took all five wickets as Pakistan finished on top on the second day of the second Test against South Africa at Newlands on Friday.
South Africa were struggling at 139 for five at the close, still 199 runs behind Pakistan's first innings of 338. Ajmal took five for 41.
Three of Ajmal's wickets came after the use of the decision review system, including a controversial dismissal of star South African batsman Jacques Kallis.
South African captain Graeme Smith and Hashim Amla were both out leg before wicket after being given not out by umpire Steve Davis.
Kallis was given out caught at short leg and immediately called for a review, which showed that the ball had not touched his bat before looping off his pad to the fielder.
But he was then given out leg before on the advice of television umpire Billy Bowden, although replays showed the ball was only brushing the outside of his leg stump, in the area known as "umpire's call".
Kallis was clearly shocked and stood at the wicket seeking clarity before reluctantly returning to the pavilion.
Controversy apart, it was a superb display of bowling by Ajmal, who bowled 25 overs unchanged into a stiff south-easterly wind, varying his flight and mixing off-spin with cleverly disguised top spinners and "doosras" which turned away from the right-handed batsmen.
Ajmal came on to bowl after 11 overs had been bowled in South Africa's innings and struck with his ninth delivery, Smith missed a sweep and Pakistan successfully sought a review.
Two overs later Ajmal had Alviro Petersen smartly caught at short leg by Azhar Ali, who dived to his right to hold a sharp chance.
Amla went back on his stumps and was also given out on review before Kallis was dismissed.
He was followed by Faf du Plessis, caught at slip off a "doosra" for South Africa's highest score of 28.
AB de Villiers and Dean Elgar survived until the close.
Earlier, Pakistan batted until lunch after resuming at 253 for five, although Philander's early strikes raised the home side's hopes of wrapping up the innings quickly.
Philander, who took five for 59, struck with his first ball of the day when Asad Shafiq was caught at first slip without adding to his overnight score of 111. Shafiq batted for 308 minutes and faced 230 balls.
Sarfraz Ahmed, the other overnight batsman, fell for 13 in Philander's next over when Petersen dived full length to his right to hold a good catch at third slip.
Umar Gul was leg before wicket without scoring as Philander completed his ninth five-wicket haul in Test matches.
South Africa suffered a blow when fast bowler Morne Morkel left the field after bowling three balls of his 21st over with what was described as a tight left hamstring.
Pakistan 338 (Shafiq 111, Younis 111, Philander 5-59)
South Africa 139 for 5 (Ajmal 5-41)
Status South Africa trail by 199 runs