Hafeez was then trapped lbw by Steyn with the second ball of Pakistan's second innings, and opening partner Nasir Jamshed also failed to trouble the scorers before being pinned in front by Philander.
Azhar and Younus took the score on to 45 before the latter (14) slashed at a wider delivery from Steyn and chopped it on to his stumps.
Azhar and Misbah set about building a patient partnership, which had reached just 10 in 9.2 overs when an injury to Morne Morkel brought forward the drinks break. The paceman limped off, with the over completed by Jacques Kallis.
Misbah's boundary off Kallis brought the first runs in 35 balls and he then broke the shackles to twice loft Peterson down the ground for six.
A third maximum followed with an over remaining, bringing up the 50 partnership and Pakistan's hundred, and he ended the day on 36 not out with Azhar five runs away from a half-century.