An unbeaten 101-run stand for the fifth wicket between Misbah-ul-Haq and Asad Shafiq kept Pakistan alive in the first Test as they reached 183 for four at the close of play on day three against South Africa at the Wanderers.
The visitors looked to be heading for a heavy defeat when they slumped to 82-4 before tea chasing down 480, but the pair batted through the final session to give Pakistan hope.
They still need 297 runs to win but with the rain predicted on the final two days all results remain possible.
Misbah (44 not out) and Shafiq (53 not out) batted patiently, seeing out 45 overs in their partnership as South Africa struggled to find a breakthrough.
In part the home side have only themselves to blame. Vernon Philander thought he had Shafiq caught at slip by Graeme Smith when the batsman was on 40, but the Pakistan right-hander was recalled after a check with the third umpire showed it was a no-ball.
In the next over Robin Peterson dropped a simple chance offered by Misbah at point off the bowling of Kallis.
With the new ball due in just five overs on Monday morning, South Africa will still be confident of forcing a result if the weather holds.
Things did not start as well for Pakistan in their second innings though. Mohammed Hafeez made just two as he glanced a leg-side ball from Philander, but succeeded only in providing wicketkeeper AB de Villiers with a catch behind the stumps.
Debutant Nasir Jamshed's stoic resistance came to an end when he attempted a pull off Dale Steyn, but got his timing all wrong and picked out Robin Peterson at mid-on four runs short of a maiden Test half-century.
Azhar Ali (18) was trapped in front by Kallis and although he chose to review the decision, the TV umpire upheld his dismissal.
Younus Khan (15) was not sure whether to play or leave a Morne Morkel delivery and in the end did neither, a faint edge being snapped up by De Villiers to leave his side four down.
Earlier in the day, South Africa made a fast start when they resumed their second innings, scoring 68 runs in just nine overs before declaring on 275 for the loss of three wickets.
Resuming on his overnight 63, de Villiers led the charge with a sparkling unbeaten century off 117 balls.
He was ably supported by Hashim Amla, who moved from his overnight 50 to 74 not out by the time Smith called the players in with 50 minutes of the morning session gone.
By that time the pair had put on a Wanderers record fourth wicket Test partnership of 176, beating the previous mark of 147 they had set against Australia in the 2011/12 season.
Photograph: Duif du Toit/Gallo Images/Getty Images