Vernon Philander claimed his ninth five-wicket haul in his 15th Test for South Africa, but a spirited ninth-wicket partnership boosted Pakistan to 338 on day two of the second Test at Newlands.
The visiting side were bowled out on the stroke of lunch on Friday, with Philander finishing with 5-59 from 26 overs.
Philander struck in the second, fourth and sixth overs of the day to reduce Pakistan to 8-268, but Tanvir Ahmed and Saeed Ajmal put on 64 for the ninth wicket to keep the innings rolling.
Spinner Robin Peterson eventually ended the stand when he dismissed Ahmed for 44, before bringing the innings to a close by bowling last man Mohammad Irfan.
Centuries by Younis Khan and Asad Shafiq transformed Pakistan’s fortunes on day one after the visitors had been reeling at 4-33 33 after being sent in.
Younis was caught behind on Thursday off Philander for 111, while Shafiq also fell on 111 to Philander on Friday.
