Ravichandran Ashwin made a crucial breakthrough late on day three as India pressed home their advantage against South Africa in the second Test.
The Proteas started Saturday on 36-3 and were all out for 275 in their first innings by the close of play, still 326 runs behind the hosts in Pune.
It could have been worse for South Africa, but India's bowlers were frustrated by a magnificent 109-run partnership for the ninth wicket between Vernon Philander and Keshav Maharaj that spanned 259 balls.
But India ended the day on top after the impressive Ashwin (4-69) claimed two vital wickets in the final four overs of the day.
South Africa were on 271-8 until Ashwin dismissed Maharaj, who had batted with a sore shoulder for a career-best 72, before the spinner also accounted for number 11 Kagiso Rabada (2), leaving Philander stranded on 44 not out.
Pace bowler Umesh Yadav took 3-37, with India – who declared on 601-5 in their first innings - looking good for a victory that would seal the series.
With two days still to play, their next decision will be whether to enforce the follow-on.
India captain Virat Kohli, who will make that call, followed up his double-hundred with the bat by taking an early catch on Saturday to remove nightwatchman Anrich Nortje off the bowling of Mohammed Shami (2-44) for 3.
South Africa were in disarray at 53-5 when Theunis de Bruyn was caught behind off Yadav for 30, with captain Faf du Plessis and Quinton de Kock left to steady the ship somewhat by combining for a quickfire 75.
Ashwin bowled De Kock for 31 before lunch, though, and Senuran Muthusamy (7) was out lbw to Ravindra Jadeja (1-81) in the third over after the interval.
Du Plessis (64) had reached his 21st Test half-century off just 64 balls but his pace slowed from there and, when Ashwin found his outside edge, the Proteas were poised for a collapse at 162-8.
However, Philander and Maharaj had other ideas with a disciplined, dogged partnership amid hot and humid conditions.
Maharaj aggravated his right shoulder – which had been injured while fielding on Friday – as he smacked Shami for four while on 17, but he bravely fought on to earn a first Test half-century in a 132-ball knock.
But Ashwin capped fine outing by having Maharaj caught by Rohit Sharma at leg slip and promptly trapping Rabada in front, with Philander unbeaten having faced 192 deliveries.