Shardul Thakur's seven-wicket haul helped reduce South Africa to 229, after which Cheteswhar Pujara and Ajinkya Rahane took India to safety after they lost their openers.
India finished the day on 85/2 but with a solid lead of 58 to build upon on day three. South Africa, on the other hand, will be ruing the missed opportunity to put on a sizeable lead.
Starting the day on 35/1, Dean Elgar and Keegan Petersen were largely untroubled by the Indian bowlers, bar a handful of half-chances that were created. The Proteas captain was given out caught behind early on but umpire review came to his rescue, with the replays suggesting that it was a bump ball.
While Elgar was far from his fluent best, he motored on while Petersen did the bulk of the run-scoring, finding boundaries regularly to keep the scoreboard ticking.
It looked like the two batters would take South Africa unscathed into lunch but Shardul Thakur's triple strike helped India wrest some control back before the break.
He broke the 74-run partnership for the second wicket by snaring Elgar caught behind. Petersen brought up his maiden Test fifty but failed to convert it into a big one. Thakur lured him with a wide delivery swinging away and Petersen fell for the trap, edging it to the second slip.
Rassie van der Dussen fell on the stroke of lunch as South Africa went from 88/1 to 102/4.
South Africa needed to consolidate after the quick strikes and it was Kyle Verreynne and Temba Bavuma that bailed them out of trouble. Mixing caution with aggression, they strung together a 60-run stand where the duo showed great application on a difficult track.
Unfortunately for South Africa, their second session was a carbon copy of the first, where they dominated for the most part but lost their way towards the end.
It was Shardul Thakur again who got India the breakthrough, trapping Verreynne in front of the stumps for 21. Bavuma reached his fifty in two overs later but was out the very next ball strangled down the leg side as Thakur completed his first Test five-wicket haul.
Mohammad Shami then get on in the act and got rid of Kagiso Rabada before tea, with South Africa still 11 runs behind India going into the break.
Marco Jansen and Keshav Maharaj, who ended up scoring 21 runs each, added crucial 38 runs for the eighth wicket before Jasprit Bumrah cleaned the latter up. Fittingly, Shardul Thakur finished the South African innings off with two wickets in four balls. South Africa were bowled out for 229, with a slender 27-run lead.
India got off to a brisk start and knocked off 24 out of South Africa's 27 run-lead before Jansen dismissed KL Rahul for 8. Agarwal was the next to walk back as he shouldered arms to a ball moving in and was adjudged leg before wicket.
India were in a spot of bother when their two most experienced batters, Cheteshwar Pujara and Ajinkya Rahane, in the game took them to safety at stumps. Pujara, in particular, showed tremendous intent even as the end of the day was approaching closer, scoring seven boundaries in his knock of 35* off 42.
https://www.icc-cricket.com/news/2439951