A blazing all-round performance by Hardik Pandya and an injury to South Africa fast bowler Dale Steyn kept India in the game on the second day of the first Test at Newlands on Saturday.
Pandya scored a swashbuckling 93, then took two wickets in South Africa's second innings as the hosts stretched their overall lead to 142 with eight wickets remaining.
South Africa, on 65-2, are in a strong position on a pitch which has helped fast bowling, but it was announced after play that Steyn, one of a four-man pace attack, had suffered a heel injury which could keep him out of action for four to six weeks.
"We are slightly ahead but we're going to have to work hard," said fellow fast bowler Kagiso Rabada, who took 3-34 in India's first innings of 209. "Three seamers will have to do the work. We have to find a way to win this Test match."
That Steyn was in his 18th over when he stepped in a foot hole in his delivery stride, and suffering what was described as a "freakish injury", and that South Africa's first innings lead was only 77 was largely due to an extraordinary innings by Pandya.
India had been reduced to 92-7 in reply to South Africa's 286 and Pandya had been tormented by a testing spell from Steyn at the start of his innings.
He survived on a review after being given out caught behind off the fast bowler on five and was dropped by Dean Elgar at gully off Steyn when he had 15.
Almost as though he flicked a switch he changed from survival to attacking mode.
He raced to a half-century off 46 balls and slammed 14 fours and a six in a 96-ball innings, although he survived a stumping chance off Keshav Maharaj when he had 71.
"He played his natural game. He likes to play his shots," said Indian teammate Cheteshwar Pujara, whose innings of 26 was eked out over 92 deliveries, in stark contrast to that of Pandya.
"He batted really well and showed a lot of character," Pujara added. "He is someone who is very promising. He's bowling well and he's batting well and he balances the team combination."
Rabada gave credit to Pandya but said his strategy would not always work.
"He likes to play his shots. Sometimes that can put you [the bowlers] on the back foot, sometimes it can pay off for the bowling side. So it's a bit of a gamble but if he plays that way and it works for him we need to find a way to counter it."
While Pandya went for his shots, Bhuvenshwar Kumar took 34 balls to score his first run but then played some fine strokes of his own, scoring 25 in an eighth wicket partnership of 99 which more than doubled their team's total.
Pandya, 24, confirmed the reputation he earned as a dashing stroke player, first in limited-overs cricket and more recently when he scored 178 runs off 168 balls in three Test innings in Sri Lanka last year, including 108 off 96 deliveries in the third Test in Kandy.
Bhuvneshwar was caught behind off Morne Morkel when Pandya was on 85.
If anything, Pandya stepped up his aggressive attitude after the dismissal of Bhuvneshwar, swinging at a succession of short-pitched deliveries bowled from around the wicket by Morkel and Rabada. His luck ran out when he flashed at a lifting ball from Rabada and was caught behind.
South Africa v India: Pitch we wanted, says Faf du Plessis
AB de Villiers: 'I feel more ready than ever to take it on'
Pujara said India were confident.
"Overall we're in a good position. We got two wickets and if we bowl well tomorrow we're very much in the game."
Pujara said batting conditions had eased since the first day, although there was always something in the pitch for the fast bowlers.