India's Rishabh Pant scored a superb unbeaten century but hosts South Africa made major strides towards winning the third and final test, and the series, as they reached the close on 101 for two in pursuit of 212 at Newlands on Thursday.
South Africa still require another 111 for victory on a difficult batting wicket that saw India bowled out for 198 in their second innings, a score significantly boosted by the impressive Pant.
Home captain Dean Elgar (30) and Keegan Petersen (48 not out) put on 78 for the second wicket in a partnership that swung the match in the home side's favour.
But Elgar was out with what proved to be the last ball of the day with a strangle down the leg side as he edged seamer Jasprit Bumrah to wicketkeeper Pant.
India were earlier furious when Elgar, who made a match-winning unbeaten 96 in the second innings of the second test, earned a reprieve from the ball-tracking technology when on 22.
The delivery from Ravichandran Ashwin was deemed to be bouncing over the top of the wicket, something the livid Indian players could be heard suggesting was impossible.
A fourth innings target of over 200 has been successfully chased only three times in 133 years at Newlands as India seek to claim a first ever series win in South Africa.
But one of those was when the hosts managed 211 for the loss of five wickets against India in 2007 to win the test.
They also successfully chased 240 in the fourth innings of the second test of this series in Johannesburg.
"If you had come to us in the morning and asked if we would take 101 for two (chasing 212), we would have taken that and run," South Africa seamer Lungi Ngidi told reporters.
"We are in a pretty good position. Another strong partnership and we are well in this game."
Pant earlier put on a batting masterclass as he scored 100 not out from 139 balls in India's second innings. Captain Virat Kohli (29) was the only other player to score more than 10.
Pant showed his array of attacking strokes and looked far more in control than any batsman in the test so far.
South Africa bowled without much luck, beating the bat with regularity, but it is the first time in test history that all 20 wickets to fall in a match for one team were caught.
Ngidi (3-21), Kagiso Rabada (3-53) and Marco Jansen (4-36) were among the wickets for the home side.
"We just tried to stick to the basics and keep it as tight as possible," Ngidi said. "When the wickets start to tumble it happens quickly (on this pitch)."