Image courtesy of: BCCI
India opener Rohit Sharma scored his second century in the match as South Africa were set 395 to win on the fourth day in Visakhapatnam.
Starting off the day on 385/8, South Africa added 11 runs to their overnight score before Keshav Maharaj was dismissed by Ravichandran Ashwin for nine runs.
South Africa ended up being bowled out for 431, which gave India a 71-run lead, when Kagiso Rabada was trapped lbw off the bowling of Ashwin for 15.
Debutant Senuran Muthusamy was left stranded on 33, which came off 106 balls and included four boundaries.
Ashwin was the pick of the bowlers with seven wickets, while Ravindra Jadeja snapped up two and Ishant Sharma chipped in with one.
With a 71-run lead in hand, India lost opener Mayank Agarwal early on as he was caught by South Africa captain Faf du Plessis at first slip off the bowling of Maharaj for seven runs.
Rohit and Cheteshwar Pujara made up for the loss of Agarwal with a 169-run partnership, during which both batsmen registered their half-centuries, before Pujara was trapped lbw off the bowling of Vernon Philander for 81, which came off 148 balls and included 13 boundaries and two sixes.
Rohit and Jadeja added 49 runs to the score before Rohit was stumped by Quinton de Kock off the bowling of Maharaj for 127, which came off 149 balls and included 10 boundaries and seven sixes.
Jadeja went on to score 40 before he was clean bowled by Rabada.
India captain Virat Kohli and Ajinkya Rahane mustered an unbeaten 37-run partnership before the hosts declared on 323/4, which set South Africa 395 to win.
Kohli ended up making 31, which came off 25 balls and included three boundaries and a six, while Rahane remained unbeaten on 27, which came off 17 deliveries and included four boundaries and a six.
Maharaj was the most successful bowler with two wickets, while Philander and Rabada claimed one wicket each.
Chasing 395 to win, South Africa were dealt a huge blow in the fourth over as Dean Elgar was trapped lbw off the bowling of Jadeja for two runs.
Theunis de Bruyn and Aiden Markram managed to forge an unbeaten seven-run partnership before bad light brought play to an end for the day.
De Bruyn finished on five, which came off 20 balls and included a boundary, while Markram remained undefeated on three.
Jadeja took the only wicket that fell.
South Africa ended day four on 11/1 and will continue batting on Sunday at 09:20 local time or 03:50 GMT.