South Africa 431 (Elgar 160, de Kock 111, Ashwin 7-145) and 11 for 1 needs another 384 runs to beat India 502 for 7 dec (Mayank 215, Rohit 176, Maharaj 3-189) and 323 for 4 dec (Rohit 127, Pujara 81) by 117 runs
Visakhapatnam: Rohit Sharma on Saturday struck a second 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.
Rohit, 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.
Rohit put on 169 with Pujara 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.
Rohit 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.
Philander said South Africa are confident of a good show come Sunday.
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.