Jacques Kallis marched to his 36th Test hundred as South Africa ended day four of the first Test with Pakistan in Dubai in complete control.
Kallis ended on 135 not out with partner Hashim Amla also unbeaten on 118 as Proteas skipper Graeme Smith declared on 318 for two midway through the afternoon session, giving Pakistan a target of 451.
They made an inroad of 109 runs into that but crucially lost two wickets in the evening session to remain 342 runs short of what would be a remarkable victory.
Their hopes rest largely on the shoulders of 25-year-old batsman Azhar Ali and the experienced Younus Khan, with the pair unbeaten at the end on 37 and 11 respectively.
Mohammad Hafeez had looked as though he could halt South Africa's victory charge with a smart 34, but he was snared by Dale Steyn before Taufeeq Umar fell to Johan Botha.
Earlier in the day, after resuming on 139 for two, Kallis and Amla opened the floodgates as they posted a third-wicket partnership of 242 - South Africa's second-highest for any wicket against Pakistan.
Kallis set the tone by hitting Saeed Ajmal's first ball of the day over the sightscreen for six.
He and his partner barely gave Pakistan a sniff, with a Kallis edge through the vacant slip cordon and Ajmal's lbw appeal against Amla the closest they came to breaking the partnership in the morning session.
Amla was the first to bring up his hundred, taking 190 balls to raise his bat for the 11th time in his career, punching Abdul Rehman through cover for a single.
Kallis followed him in the next over, taking five balls less for his fourth century of the year which came up with a single off Umar Gul.
The Pakistan attack were run ragged by the duo throughout, with Kallis dispatching Ajmal for 16 in one particular over, the highlight of which was a sumptuous six.
With everyone waiting for Smith to declare, there was still time for Gul to drop an easy chance to end Kallis' knock on the boundary but he failed to do so and Smith called his men in shortly after.
Steyn thought he had taken Hafeez in the third over but his seemingly sound lbw appeal was turned down by Daryl Harper, and he had to wait until the 14th over to do so, with Botha taking a comfortable catch after Steyn found the edge.
The wicket stifled Pakistan's momentum and they made it to 62 for one before South Africa nearly unlocked their defences again, with an edge off Taufeeq falling short of AB De Villiers.
Taufeeq managed to crawl to 22 before his spell at the crease ended, with man of the moment Kallis diving to his left to take him off Botha.
Ali and Younus steadied the ship through to the close, and although South Africa remain in charge, they will be slightly concerned after seeing Steyn receive treatment to an elbow problem in the outfield.