A fighting innings from captain Inzamam-ul-Haq and two wickets from pace bowler Mohammad Asif put Pakistan on top after the second day of the Second Test in Port Elizabeth.
Resuming on 135 for 6, in reply to the home side's paltry first-innings total of 124, Pakistan were finally bowled out for 265, thanks largely to a gutsy knock from Inzamam. Batting at No 8 because of a shoulder injury, he finished on 92 not out - his 46th Test half-century - off 142 balls, with 13 boundaries.
Makhaya Ntini gave the South African camp something to cheer about, claiming his 300th Test wicket, when Mohammad Sami edged the ball to wicketkeeper Mark Boucher for 10, and his 17th Test five-wicket haul to prevent Pakistan taking complete control.
South Africa began their second innings 141 in arrears and soon lost captain Graeme Smith, who was caught for 10 by Inzamam off the bowling of Asif, who was opening the bowling in place of the injured Shoaib Akhtar.
Asif then bowled Smith's opening partner, A B de Villiers, for 15, and his fellow fast bowler Mohammad Sami castled Hashim Amla for 16 to leave the hosts struggling.
However, an unbroken fourth-wicket stand of 54 between Jacques Kallis (50 not out) and Ashwell Prince (21 not out) - the pair who guided South Africa to victory in the First Test - ensured that the Proteas finished day two on 115 for 3, just 26 behind.