Chasing 287 runs for a series-equalising win, India faltered from the start in their second innings chase and lost three quick wickets to close the penultimate day of their second cricket Test against South Africa at 35 for three here on Tuesday.
India lost openers Murali Vijay and Lokesh Rahul and skipper -- and first inning centurion -- Virat Kohli to the South African pace battery before they could even settle down.
Cheteshwar Pujara (11) and Parthiv Patel (5) were at the crease when umpires called end of play for the day.
For South Africa, Lungisani Ngidi scalped two wickets while Kagiso Rabada took one wicket.
Chasing a target of 287 runs, the visitors lost opener Murali Vijay early on when a Rabada delivery pitched outside off and nipped sharply in to hit the stumps.
Vijay's fellow opener Lokesh Rahul departed shortly afterwards when he handed a soft catch to Keshav Maharaj at point off Ngidi's bowling.
Ngidi then struck a crucial blow to the visitors when he sent back the in-form Kohli a short while later. The Indian captain never looked comfortable during his 24-ball stay in the middle and was trapped leg before when he misjudged a low, incoming delivery.
Earlier, India bowled out South Africa for 258 in their second innings and set themselves a 287-run target. AB de Villiers (80) and captain Faf du Plessis (48) were the key contributors for the hosts at the SuperSport Park.
For India, Mohammed Shami was the pick of the bowler, taking 4/49, while fellow fast bowler Jasprit Bumrah bagged three wickets for 70 runs.
Resuming their second innings at the overnight score of 90/2, the Proteas rode on the partnership of de Villiers and Elgar as they threatened to take the game away from India. The duo had joined hands with South Africa struggling at 3/2 and on Tuesday, they continued from where they left off, adding 141 runs between them to pull the hosts out of trouble.
Both of them looked bright and maintained a very healthy rate in the first hour of the day with boundaries coming their way easily at regular intervals. De Villiers was in control against the Indian bowlers while Elgar, who completed his ninth Test half-century, was resolute.
Shami shines on Day 4
Shami however, took three wickets to pull India back into contention as they reduced South Africa to 173/5 at lunch. The Bengal fast bowler removed de Villiers, Elgar and Quinton de Kock in the first session as the hosts managed to add 83 runs to their overnight score before lunch.
Shami got the first breakthrough of the day for India when a rising delivery kissed de Villiers' gloves for an easy catch to wicket-keeper Parthiv Patel. Soon, Elgar pulled one straight into the hands of Lokesh Rahul at deep square leg as the hosts lost their fourth wicket for 151 runs.
It could have been 151/5 had Rahul pulled off a half chance at short-leg off du Plessis, who was then on six. Du Plessis struggled against off-spinner Ravichandran Ashwin and managed to push it to the right of Rahul.
Shami continued his impressive spell as he got rid of de Kock, who edged an away-moving ball to Parthiv, leaving his side at 163/5. Du Plessis and Philander then negated the Indian bowlers till the umpires called for lunch.
Philander frustrates India once again
Faf du Plesis and Vernon Philander then batted steadily to help the hosts post 230/7 by the tea break. The duo batted together for most of the post-lunch session and added 45 runs between them as the hosts increased their lead to 258 runs.
Du Plesis remained unbeaten on 37 runs at the break with Kagiso Rabada yet to open his account at the other end.
Philander scored a patient 26 off 85 balls with two hits to the fence before being caught by Murali Vijay at square leg after hitting out at a short pitched delivery from Ishant Sharma. The rest of the South African tailenders also batted patiently to frustrate the Indian bowlers.
Ishant bowled with pace and aggression, putting the Proteas batsmen under pressure on several occasions and was rewarded with a couple of wickets after lunch.
Philander was the very picture of resolute defence during his innings. But he eventually lost his patience and lashed out at an Ishant delivery which cost him his wicket. Keshav Maharaj did not last very long before falling to another excellent delivery from Ishant just before Tea.