India set South Africa a tricky 240-run target to win the second Test after being bowled out for 266 in their second innings on the third day of the match in Johannesburg on Wednesday.
Resuming at 85 for two, India called the shots with Cheteshwar Pujara (53) and Ajinkya Rahane (58) striking half-centuries.
Once they were dismissed by Kagiso Rabada, the Indian innings seemed to have lost momentum with Rishabh Pant falling without opening his account.
However, Hanuma Vihari (40 not out) and Shardul Thakur (28) defied the Proteas attack to swell India's overall lead.
Pacers Rabada (3/73), Lungi Ngidi (3/43) and Marco Jansen (3/67) shared nine wickets between them.
If India manage to defend the total, they will seal their maiden Test series triumph in South Africa.
Brief Scores: India 202 and 266 (Ajinkya Rahane 58, Cheteshwar Pujara 53; K Rabada 3/73, M Jansen 3/67, L Ngidi 3/43) lead South Africa 202 by 239 runs