South Africa captain Graeme Smith broke a two-year century drought to put Pakistan on the ropes on day four of the second Test.
Smith, unbeaten on 100 for his first Test ton since May 2005, shared a third-wicket stand of 145 with Jacques Kallis to take the tourists to 211-2 at lunch at the Gaddafi stadium.
With Kallis on 69 not out, the Proteas now lead by 362 runs with eight wickets intact on a deteriorating pitch.
South Africa, 1-0 up after their 160-run win at Karachi, are now in a commanding position for their first series win against a major subcontinental team since 2000.
Smith, 75 overnight, went into a shell after entering the 90s but pushed part-time bowler Younis Khan for a couple in the last over before the interval to complete his century.
He has batted nine minutes short of six hours and has so far hit 12 boundaries for his 12th century and first in 17 Tests.
Smith's last Test hundred came against the West Indies at Antigua in May 2005.
Smith and Kallis continued to punish a hapless Pakistan attack after the tourists resumed at 154-2.
The home team were depleted by the loss of paceman Mohammad Asif, who suffered a recurrence of an elbow injury on Wednesday.
Scans revealed Asif has inflamation in his elbow and needs a week's rest to recover, ruling out any chances of him bowling in this match. He bowled just four overs in South Africa's second innings.
Asif's new-ball partner Umar Gul, who took one wicket, also had to return to the dressing room due to fatigue leaving Pakistan with only two frontline bowlers in the hour before lunch.
To add to their bowling woes Pakistan fielded poorly. Captain Shoaib Malik failed to catch an uppish shot from Kallis off left-arm spinner Abdul Rehman at long-off when the South African was on 47.
Kallis went on to complete his 46th Test half-century, which included five boundaries.