Dean Elgar and Quinton de Kock kept the skilful Indian spinners at bay with memorable hundreds, orchestrating South Africa's spirited counter-offensive against the fancied hosts in the first Test.
Elgar (160 off 287) got valuable support from skipper Faf du Plessis (55) and Quinton de Kock, whose aggressive knock of 111 off 163 balls took South Africa closer to India's first innings total of 502.
Off-spinner Ravichandran Ashwin brought the home team back in the final session with a double strike, picking up his 27th five-wicket haul in Tests in the process.
Ravindra Jadeja also reached a milestone when Elgar top-edged a sweep to Cheteshwar Pujara at deep mid-wicket, giving the spinner his 200th Test wicket.
At close of play, the visitors were 385 for eight in 118 overs, trailing India by 117 runs.