Sri Lanka were 256/7 in their second innings, an overall lead of 426 runs with two days still to go.
Durban: Kumar Sangakkara's 108 put Sri Lanka in complete control of the second Test against South Africa on Wednesday and on course for a breakthrough first win in the country.
Sangakkara's 28th Test century and first in South Africa propelled Sri Lanka to 256-7 in their second innings and a huge lead of 426 with three wickets in hand and two days still to play at Kingsmead.
The stylish left-hander survived a dropped catch in the first over of the day when he was on 3 and cashed in with a stroke-filled return to form in his first big score this series.
His century, sharing partnerships of 94 with Thilan Samaraweera (43) and 104 with impressive debutant Dinesh Chandimal (54), helped ensure South Africa would have to make a world-record winning score in the fourth innings to steal the match — or bat for long periods just to draw it.
Having posted 338 in their first innings, and skittling out South Africa for 168, Sri Lanka were in a dominant position to level the three-match series and send it to a decider in Cape Town. It would also be the Sri Lankans' first ever Test win in South Africa and complete a dramatic turnaround in this contest after they were blown away to lose the series opener by an innings just over a week ago.
Sangakkara hit 13 fours and lifted Sri Lanka from 44-3 and early trouble after an hour delay at the start of the day in Durban because of rain.
By the time he lofted a mistimed drive to Graeme Smith at mid-on off legspinner Imran Tahir (2-64) to fall two balls after Chandimal and three overs from the close of play, the job was done and South Africa had effectively been batted out of the match.
Fast bowler Dale Steyn returned 3-54 for the home team but South Africa's frustration was evident with Steyn's verbal onslaught at Chandimal shortly before he got the young wicketkeeper batsman out.
South Africa took six wickets on the day, yet Sangakkara's classy century — combined with Sri Lanka's 170-run lead after the first innings — looked set to continue the home team's miserable run at Kingsmead.
The Proteas have lost their last three Tests at the ground and fell to India last time they played here having also won the first match of the series by an innings.
Debutant fast bowler Marchant de Lange's 7-81 in the first innings and eight wickets so far in the match was set to be lost in South Africa's disappointment.
Sangakkara hadn't settled when he sent an edge between wicketkeeper Mark Boucher and first slip Smith and with Boucher initially going for the catch and missing it, Smith spilled the chance.
The top-ranked Test batsman made them pay, driving, cutting and sweeping his way to the highest score by a Sri Lankan in South Africa. Successive boundaries off Jacques Kallis saw him race through the 90s before a square drive for two took him past 100 and put Sri Lanka on course for a desperately needed first Test win in 16 matches.
Resuming on 7-1, Sri Lanka had lost Tharanga Paranavitana (9) and Mahela Jayawardene (14) early before the crucial stand between Sangakkara and Samaraweera took the game away from South Africa.
A centurion in the first innings, Samaraweera was bowled by Tahir and Angelo Mathews edged behind off Steyn to give South Africa a glimmer of hope of holding back Sri Lanka's surge with the visiting team 141-5.
But Sangakkara followed up the stand with Samaraweera with a century partnership with Chandimal, who registered his second half-century of the match to help put the tourists in complete command.