The retiring Mahela Jayawardene hit a solid 165 in one of his last few Test innings to give Sri Lanka the edge on the second day of the second match against South Africa on Friday.
Jayawardene, due to quit Test cricket next month, hit 17 fours and a six during his nearly eight-hour stay at the wicket, laying down the foundation for a strong first innings total.
At lunch, Sri Lanka were 395-6 with Test debutant Niroshan Dickwella batting on 63 and Dilruwan Perera on nine.
Jayawardene, who was run out by a direct hit from Alviro Petersen about 30 minutes from lunch, shared a rollicking 100-run stand with Dickwella who showed a lot of promise in his 103-ball knock.
It was Dickwella who dominated the bowlers initially when Sri Lanka resumed at their overnight 305-5, driving and cutting South African fast bowlers for fours to belie his status as a Test debutant.
Jayawardene too picked up the pace, reaching the 150-run mark with a single to long leg off Dale Steyn.
The South African quicks struggled to make the new ball count in the crucial first hour, regularly pitching in loose balls that were promptly dispatched to the fence.
Morne Morkel's short balls were hit for two fours on the trot by Dickwella, the batsman arching back slightly and ramping the second one high over the slip cordon.
The attritional first hour saw Morkel lose his cool and push away Dickwella as he was trying to take a run but the bowler apologised immediately.
The Proteas, apparently frustrated at their lack of success, sought a review when Dickwella was on 44 but TV replays showed the ball had only hit his chest before being caught in the slips.
Unruffled, Dickwella went on to complete his debut Test fifty with three runs off a full toss from Morkel that he nudged it to the mid-on region.
With the fast bowlers failing to make a dent, new Test skipper Hashim Amla brought on the spinners but without luck.
Part-time spinner JP Duminy was lofted over the long-on fence for a six by Dickwella and leg-spinner Imran Tahir looked harmless.
The hosts added 90 runs in the session while losing the wicket of Jayawardene.
South Africa lead the two-Test series 1-0 after winning the first match in Galle by 153 runs.