South Africa, seeking a clean sweep of the series, went to the close on 135 for five in their second innings, a lead of 212 runs in a test that is rapidly moving forward with 25 wickets falling in only six sessions.
Hashim Amla (42 not out) and Quinton de Kock (34 not out) will seek to set the tourists a challenging target on day three, with anything over 250 likely to trouble a Pakistan batting lineup that has battled the hostile home seam attack all series.
Olivier was the pick of the bowlers for South Africa with 5-51 as his pace and steep lift off the wicket restricted Pakistan to 185 in their first innings, the visitors losing their last five wickets for 16 runs.
Babar Azam (49) and captain Sarfraz Ahmed (50) mounted an excellent fightback after lunch with a 78-run sixth-wicket partnership in 10 overs before the latter edged seamer Kagiso Rabada (2-41) to Amla at second slip, precipitating a collapse.
It will be relief for South Africa coach Ottis Gibson, who had seen his side drop four catches in the morning session to let the visitors off the hook with unusually sloppy fielding.
Tall fast bowler Olivier now has 21 wickets in the series, a South African record in a three-match tour against Pakistan and four short of the country's all-time record-holder Buck Llewellyn, who achieved the feat against Australia in 1902.
"We're in a good position but it's still a massive day tomorrow, we need to bat as long as possible and get a big lead and then bowl well again," Olivier told reporters at the close of play.
"There is enough in the wicket for the bowlers if you hit the right areas. There are a few cracks opening but there is also value for shots for the batsmen if you get yourself in."
It suggests there is a lot in the wicket for the bowlers but despite some sideways movement and the usual bounce that comes with the Wanderers pitch, there has not been prodigious assistance.
That was the case in the South African second innings as they looked to build on their 77-run first-innings advantage.
Stand-in captain Dean Elgar (5) failed with the bat for the second time in the match when he edged to Ahmed off Mohammad Amir as Pakistan made a solitary breakthrough before tea.
Aiden Markram (21), Theunis de Bruyn (7) and Themba Bavuma (23) were all also caught behind the wicket, while debutant Zubayr Hamza (0) was trapped leg before by Faheem Ashraf (2-19).
There were numerous stoppages in the evening session after a swarm of small insects took up residence near the wicket, forcing aborted run-ups by the Pakistan pace attack and leading to the rare sight of seamer Hasan Ali bowling with sunglasses to avoid the intruders flying into his eyes. (Reporting by Nick Said; Editing by Ken Ferris, Amlan Chakraborty and Clare Fallon)
(This story has not been edited by Devdiscourse staff and is auto-generated from a syndicated feed.)