Run machine Rohit Sharma struck his second century of the match to help India set South Africa a daunting victory target of 395 on the fourth day of the first test on Saturday.
South Africa was 11-1 when bad light ended play for the day, Ravindra Jadeja having trapped first-innings centurion Dean Elgar lbw for 2, after the home team had declared on 323-4.
Sharma followed up his 176 in the first innings with 127 in the second, hitting 10 fours and seven sixes in his 149-ball knock.
The total of 13 sixes he struck in the match is the most by an Indian batsman in any test. He also became the first player from his country to score centuries in both innings of his maiden test as opener.
Sharma joined compatriots Vijay Hazare, Sunil Gavaskar (three times), Rahul Dravid (twice), Virat Kohli and Ajinkya Rahane by recording two hundreds in the same test.
On the downside, he added an unwanted record by becoming the first Indian to be stumped twice in a test, having been dismissed by Keshav Maharaj for the second time in the game.
Sharma, who struck the fifth test century of his career, put on 169 for the second wicket with Cheteshwar Pujara (81).
Pujara was lbw to Vernon Philander after tea, which prompted India to push Jadeja up the order for some quick runs. He obliged with 40 off 32 balls, including three sixes.
Kohli (31) and Rahane (27) were the unbeaten batsmen when India declared.
Earlier, off-spinner Ravichandran Ashwin ended with 7-145 as South Africa added 46 runs to its overnight score to finish on 431 all out.