South Africa is favorite to win now and take the early lead in the three-match series but the margins were fine.
A target in excess of 200 has traditionally proved a challenge in the fourth innings at SuperSport Park and the result is still not guaranteed, especially on a pitch where the fast bowlers have been dominant over the first two days and the game has raced toward a conclusion, which will likely come well inside three days.
"Hopefully we can kill off that target as soon as possible," South Africa's Temba Bavuma said, recognizing that the pitch was "tricky."
"There's a lot of sideways movement," he said, "there's definitely something out there for the bowlers and the batters really have to knuckle down."
Pakistan was 181 all out in its first innings and South Africa 223 all out in reply to illustrate the challenge of batting on this Centurion strip. All 30 wickets in the test so far have fallen to pace bowling and 15 wickets have fallen in each of the first two days.
Rabada finished with 3-47 in Pakistan's second innings and six in the match to back up Olivier's best-ever test performance. Olivier, playing just his sixth test and first in over a year, was only in South Africa's lineup after injuries to quick bowlers Vernon Philander and Lungi Ngidi.
He seized his chance and his match figures of 11-96 were the 11th-best performance by a South African in a test and the second-best ever by a home bowler at SuperSport Park.
Pakistan had seemingly forced its way back into the match by reaching 100-1 for a 58-run lead by tea. Opener Imam-ul-Haq went on to make 57 and No. 3 Shan Masood — a late injury call-up for the tourists — hit 65.
The Pakistan innings fell away after that, losing five wickets for 25 runs in the midst of the sudden collapse.
Pakistan has never won a test series in South Africa but came with high hopes this time of ending that drought, backed by a pace-bowling attack that has threatened to match South Africa's quicks.
Those visiting quick bowlers did their job earlier, with Amir and Shaheen Afridi taking four wickets each to keep South Africa in check in its first innings of the series and allow the Proteas only a slim 42-run lead.
South Africa's batting was saved by a half-century from middle-order batsman Bavuma — who passed a late fitness test on a hamstring injury to play — and 45 down the order from wicketkeeper Quinton de Kock.
- AP