JP Duminy scored his fourth Test century and his first in the subcontinent to steer South Africa to a first innings total of 455 for nine wickets declared on the second day of the first Test against Sri Lanka on Thursday.
At close, Sri Lanka openers Kaushal Silva (eight) and Upul Tharanga (20) had survived 12 overs to take the hosts to 30 for no loss.
Batting at number eight, Duminy completed his well-composed 100 not out, including 10 fours, with support from the tailenders.
He reached the mark with a single to square leg off Dilruwan Perera, who had earlier dropped him on 82 at mid-off.
Morne Morkel stayed at the crease for 74 balls, scoring a defiant 22, to help Duminy reach his hundred in a ninth-wicket stand of 66 runs.
Perera accounted for Morkel's wicket as the batsman went for an expansive drive and missed the ball altogether, to end with figures of four for 162.
The visitors batted to a plan to occupy the crease for as long as possible and wear out the pitch using up 166.2 overs in their first innings.
An eighth-wicket stand of 75 between Duminy and Vernon Philander frustrated the Sri Lankan bowling attack, which was missing one of their front-line bowlers.
Philander defended for almost two hours, facing 96 balls for 27, before skipper Angelo Mathews provided Sri Lanka with the only wicket of the afternoon session by trapping him leg before.
The hosts were handicapped by the absence of paceman Shaminda Eranga, who did not take the field after having eight stitches into the webbing between his right thumb and index finger after his injury on Wednesday.
"We are hoping that he will be able to bowl in the second innings," Sri Lanka manager Michael de Zoysa told reporters.
Earlier, wicketkeeper-batsman Quinton de Kock (51) struck six fours during his maiden Test half-century before he edged a sharply turning ball from Perera to Mahela Jayawardene at slip.
Image: JP Duminy pulls one through midwicket
Photograph: Dinuka Liyanawatte/Reuters