Rohit Sharma on Saturday struck a second successive hundred in his debut as Test opener to help India set South Africa a daunting 395 to win the opening match of their series.
The hosts declared their second innings on 323 for four in the final session of day four in Visakhapatnam.
South Africa were 11 for one at stumps with Aiden Markram, on three, and Theunis de Bruyn, on five, at the crease
The visitors need another 384 runs and India nine wickets on the final day to get ahead in the three-match series.
Ravindra Jadeja struck early after trapping first-innings centurion Dean Elgar for two in the fourth over of the innings.
The left-handed Elgar, who made 160 in the first innings, was given not out by the on-field umpire only for India to get the decision overturned with a TV review.
Markram and de Bruyn then played out the remaining overs from spinners Ravichandran Ashwin and Jadeja until bad light forced the extended play -- to make up for lost time due to thunderstorm on day one -- to be called off.
Sharma, who made 176 in India's first innings of 502 for seven declared, is the first batsman to hit two tons in his first match as a Test opener.
He also hit 13 sixes, the most in a Test match, breaking Wasim Akram's record of 12.
Sharma put on 169 with Cheteshwar Pujara, who made 81, to frustrate South Africa after the loss of opener Mayank Agarwal for seven.
Pujara was trapped lbw by Vernon Philander after he completed his 21st Test half-century.
Sharma survived a reprieve on 50 when he was caught at the boundary off Dane Piedt. Replays indicated that fielder Senuran Muthusamy's foot had touched the rope.
He was finally stumped off Keshav Maharaj as he attempted a big hit.
Jadeja hit a 32-ball 40 before being bowled by paceman Kagiso Rabada.
Maharaj struck before lunch, grabbing the key wicket of Agarwal, who hit 215 in the first innings, but the bowlers then struggled.
Earlier, Ashwin completed a haul of seven wickets as South Africa were bowled out for 431 in the morning session.
Ashwin got overnight batsman Maharaj out for nine and then trapped Rabada, leaving the Proteas 71 runs behind.
Elgar was the hero of the South African innings with his 12th century that revived the tourists' batting after they had slipped to 63 for four.
His century partnerships with skipper Faf du Plessis, who made 55, and Quinton de Kock, who hit 111, were key to the Proteas fightback.
Featured image courtesy: AFP/ Noah Saleem