At tea South Africa were 277 for six, a lead of 136. Pakistan were dismissed for 265 in reply to South Africa's first innings of 124.
Asif bowled with pace and accuracy to take four for 53 from 32 overs.
After South Africa resumed on 115 for three, Jacques Kallis and Ashwell Prince took their fourth wicket partnership to 56 before Prince (22) was trapped in front by leg-spinner Danish Kaneria with a delivery that turned sharply into the left-hander's pads.
Herschelle Gibbs joined Kallis to share 78 runs for the fifth wicket, a stand that was ended 18 balls after lunch when Gibbs, who scored 40, edged a delivery from Asif and was well caught low down by Younis Khan at second slip.
Pakistan might have separated them with the total on 142 for four when Kallis, on 63, edged a delivery from Kaneria only for wicketkeeper Kamran Akmal to drop the catch.
The circumspect Kallis was eventually dismissed for 91 in the seventh over after lunch when he was lbw to Asif. Kallis batted for almost five hours and faced 226 balls.
Mark Boucher and Shaun Pollock raised the scoring rate in their unbroken stand of 72 for the seventh wicket. Boucher was 42 not out at tea with Pollock on 31.
Pakistan were without fast bowler Shoaib Akhtar, who has yet to take the field in South Africa's second innings because of a hamstring injury.
Shoaib took four for 36 in the first innings, his first Test since he played against India in Karachi in February.