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. Earlier, Pakistan batted until lunch after resuming at 253 for five. Vernon 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.
Photos: Akshay Kumar, Taapsee Pannu promote 'Naam Shabana'
Flashback: When sexy models sizzled in bikinis at Tokyo fashion show
Photos: These Indian cities top the list in online purchase of sex products
In pictures: Indian-origin artistes in Hollywood
Photos: Varun Dhawan and Alia Bhatt at studio in Bandra