Rishabh Pant hit a thrilling century for India and followed up with a crucial catch to break South Africa's progress towards chasing down a victory target of 212 on the third day of the third Test at Newlands on Thursday.
South Africa were 101 for two at the close, 111 runs short of clinching the match and a series which is tied at 1-1.
Pant made 100 not out off 139 balls, hitting six fours and four sixes, but received minimal support from his teammates as India were bowled out for 198.
South African captain Dean Elgar, the star of a similar chase in the second Test in Johannesburg, looked set to see out the day in partnership with in-form Keegan Petersen but fell to a diving leg side catch by Pant off Jasprit Bumrah in the last over of the day. He was out for 30.
Petersen, South Africa's top-scorer with 72 in the first innings, was unbeaten on 48.
Pant, batting with unorthodox flair, ran out of partners in a poor Indian batting performance but was able to notch his fourth Test century before the last wicket fell.
Indian captain Virat Kohli made an unusually subdued 29, batting for more than three hours and facing 143 balls but the next highest contributor to the total was 28 extras.
Left-arm fast bowling discovery Marco Jansen took four for 36 – his third four-wicket in three Tests – and Kagiso Rabada and Lungi Ngidi took three wickets each.
Ngidi made a crucial breakthrough when he had Kohli caught at second slip soon after lunch.
He followed up by dismissing Ravichandran Ashwin and Shardul Thakur in quick succession, exposing the Indian tail.
Pant and captain Kohli put on 94 for the fifth wicket after India lost two wickets in the first two overs of the day after resuming on 57 for two.
Cheteshwar Pujara, without adding to his overnight score of nine, glanced the second ball from Jansen and Petersen flung himself to his right from leg slip to take an astonishing catch.
Ajinkya Rahane scored a single but then gloved a lifting ball from Rabada.
A leaping wicketkeeper Kyle Verreynne got the fingertips of his right glove to the ball and Elgar moved quickly from first slip to complete the catch.
Out-of-form South African opener Aiden Markram made 16, all from boundaries but was then caught sharply at third slip by KL Rahul.
Having escaped with an extravagant drive which flew between third slip and gully, Markram repeated the shot against the next ball and was out with the total on 23.
India appeared to have made a crucial breakthrough when Elgar was given out leg before wicket to Ashwin when he missed a delivery angled in from around the wicket. He was on 22 and the total on 60.
Elgar sought a review of umpire Marais Erasmus' decision.
It seemed an optimistic challenge but the ball tracking technology showed the ball was going just over the top of the stumps.
Kohli and his team seemed astonished at the outcome and Kohli shouted into the stump microphone at the end of the over.
Elgar continued to bat doggedly. Although he added only eight more runs, the partnership with Petersen grew by another 41 runs.
Elgar was then given not out by umpire Adrian Holdstock but a review by India showed a faint spike as the ball swung down the leg side.