South Africa 584 for 9 declared and 173 for 4 (Amla 62, Rehman 3-73) lead Pakistan 434 (Azhar 90, Misbah 77, Steyn 4-98) by 323 runs
Pakistan scrapped with all they have to prevent South Africa from bursting into a winning position on the fourth day at the Shaikh Zayed Stadium. Though South Africa still hold all the aces, they aren't quite in the position they would have aimed for at the day's start. A draw, and a drawn series, make no mistake, will be a result Pakistan are happy with.
At the centre, with bat and ball, was Abdur Rehman, an unlikely star. Rehman began with a maiden fifty that marshalled a lower-order recovery. Later in the afternoon, as Hashim Amla propelled the quest for a quick second innings declaration, he picked up three wickets to disrupt South Africa's progress.
Rehman first featured with the bat, having seen the curse of Misbah-ul-Haq strike; the Pakistan captain has found odd ways and inopportune moments to lose his wicket throughout his career. Having batted well yesterday, his dismissal to the morning's first ball was almost predictable.
The tail's response was by turns plucky and fortunate. Rehman shared stands of 36 with Umar Gul and 59 with Tanvir Ahmed to help them past vital landmarks; first the follow-on was avoided, they then reached 400 for the first time in 2010, and eventually ended on their highest total since December 2009.
Gul, who has the free-swinging manner of a tailender who is not quite good enough to be a solid number eight, set the tone. As he showed at Trent Bridge earlier in the year, he is a clean hitter. While his first boundary was a leading edge off Steyn, he crunched boundaries through the covers in successive overs from the world's best fast bowler.
The pattern, of fortune mixed with inappropriately authoritative strokeplay, was set. Rehman ducked under a bouncer but left his bat hanging. The ball duly flew off the edge. Other edges brought him useful runs, but there was also a fine cut off Jacques Kallis just after drinks.
Tanvir ducked under a Kallis bouncer later, only to see the ball fly off his bat, which stood straight up like a periscope. He followed that by whipping and punching two more boundaries with such dismissive élan it could well have been Caribbean.
Rehman danced down to loft Paul Harris over long-on in the next over and a single from the next ball meant South Africa would have to bat again. By then an air of solidity entirely absent from his bowling had settled on him, and Tanvir prolonged a fine debut until after lunch.
Rehman continued being a nuisance, however, and an accomplished one. First he guided Morkel through point, before ramping him over slips to bring up his half-century. By the time he was gone, more useful runs had been added for the last wicket, and Pakistan could realistically consider a draw.
South Africa, when Steyn wasn't around, lacked fizz with the ball. But with the bat they sparkled initially. Amla - opening in place of Graeme Smith who injured his thumb in the field - and Alviro Petersen began with a blaze of boundaries. The plan seemed clear: blitz to a lead of 350-plus and maybe have a crack late in the day at a potentially fragile Pakistan.
Eleven boundaries came in the 15.2 overs until tea, as Amla made it 1000 Test runs in a calendar year for the first time, in the process becoming the only South African to make 1000 runs in Tests and ODIs in the same year. Pakistan were quickly drifting out of the game, not attacking at all and leaking easy runs.
Amla completed an almost mandatory fifty after tea; in nine international innings on this tour he has two hundreds and four fifties. But then Rehman popped up again. He had already sent back Petersen on the stroke of tea, but he dismissed Amla with the left-arm spinner's delight, drifting in to middle and clipping off-stump.
AB de Villiers was tricked soon after and suddenly, South Africa's runs and drive dried up, as Rehman began getting more turn. Having been 112 for 1 after 20 overs, they only collected 45 runs in the next 20 overs; in these passages can be found the difference between great sides and just very good ones. Thoughts of a declaration today evaporated as Pakistan, to a limited but persistent Adnan Akmal soundtrack, slowed down proceedings and lived to fight another day.
The surface was flirting with spin late. Tomorrow still promises to be a tough, long day for Pakistan but it could have been much worse.
Osman Samiuddin is Pakistan editor of Cricinfo