Dubai: Pakistan were staring defeat in the second Test in the face after South Africa out-batted them and then bowled well on the third day in Dubai on Friday.
South Africa, seeking a series-levelling win, once again rocked Pakistan's top order with three early wickets after compiling a mammoth 517 in their first innings for a big 418-run lead at Dubai stadium.
At the close, Pakistan captain Misbah-ul Haq (42) and Asad Shafiq (28) were at the crease but they still need a whopping 286 runs to avoid an innings defeat or bat out two days to force a draw.
The duo have added 62 for the fifth wicket and would need a Herculean effort to avoid defeat.
But South Africa's bid for victory, and keeping their seven-year unbeaten away series record, was tainted when they were docked five penalty runs by the onfield umpires after television replays showed Faf du Plessis apparently trying to tamper with the ball in Pakistan's 31st over.
The two umpires, Rod Tucker of Australia and Ian Gould of England, called South African captain Graeme Smith for a warning, changed the ball and added five penalty runs to Pakistan's total.
Under International Cricket Council rules, if the umpires lay charges against any player match-referee David Boon will summon the player.
But even that South African setback couldn't save Pakistan as they continued to slump after finding themselves on two for two at lunch.
Dale Steyn gave South Africa an ideal start as he removed Shan Masood with the fourth ball of the innings, having him trapped in front of the wicket with a sharp delivery for nought.
It became two for two when Khurram Manzoor fell for his second duck of the match, caught off a miscued drive off Vernon Philander from the fifth ball of the second over.
Manzoor had made 146 in Pakistan's seven-wicket in last week's Abu Dhabi Test.
Azhar Ali and Younis added 46 for the third wicket before part-time spinner Jean-Paul Duminy struck with his first ball, trapping Ali lbw with a low delivery for 19.
Duminy could have taken Younis on 28 but Kallis failed to hold a low catch in the slips.
Younis was finally bowled for 38 by leg-spinner Imran Tahir off a strange shot, who took a career-best 5-32 to dismiss Pakistan for a paltry 99 in the first innings.
Earlier, South Africa were bowled out for 517 in their first innings on the third day.
Resuming on 460-4, South Africa lost AB de Villiers for 164 and Graeme Smith on 234 after they put on a record 338-run partnership.
South Africa took a huge 418-run lead over Pakistan's first innings total of 99.
For Pakistan off-spinner Saeed Ajmal finished with 6-151 while paceman Mohammad Irfan took 3-102 after an extended two-and-a-half hour session due to Friday prayers.
Pakistan lead the two-match series 1-0 after winning last week's first Test in Abu Dhabi by seven wickets.
Brief scores
Pakistan 99 and 132 for 4
South Africa 517 (Smith 234, de Villiers 164, Ajmal 6-151)
Status Pakistan trial by 286 runs