South Africa put up a brave fight on the third day of the second Test against India before being bowled out close to stumps in Pune on Saturday.
Left-arm spinner Keshav Maharaj, batting at No 10, battled pain as he kept the hosts at bay with a decisive half century.
After the South Africans were reduced to 139-7, it seemed like the No1 Test side would run all over the Proteas.
But the South Africans pushed the score to 275, with Maharaj and Vernon Philander showing great fight.
Maharaj made 72 with an injured shoulder, while seamer Philander remained unbeaten on 44. The two added 109 for the ninth wicket to frustrate the Indians.
"It's (shoulder) very sore. Yesterday I dived on it so lot of bruising. But hopefully I'll be fine for the rest of the series," Maharaj was quoted as saying by AFP.
"Vernon and I said to ourselves that we'll just get through to tea and see after that. Being a lower order batsman your fingers do itch to play a big shot but Vernon kept me in a good mind space.
"After a few pulls I felt normal (in the shoulder). It's better to be positive, because if you go into your shell a ball with your name will come along sooner or later."
Off-spinner Ravichandran Ashwin broke the stand and then dismissed Kagiso Rabada, finishing with figures of 4-69. Fast bowler Umesh Yadav took 3-37.
The Proteas, who resumed on 36-3, slipped to 162-8 after captain Faf du Plessis edged Ashwin to first slip.
Fast bowler Mohammed Shami struck early to remove nightwatchman Anrich Nortje for three when he edged a delivery to Virat Kohli at fourth slip. Theunis de Bruyn was caught behind off Yadav for 30 as the tourists slipped to 53-5.
Wicketkeeper-batsman Quinton de Kock put on a 75-run fourth wicket stand with du Plessis before Ashwin bowled the keeper for 31 of a superb delivery that beat his defence to hit the stumps.
Kohli had earlier hit a career-best 254 not out to surpass Don Bradman's Test tally of 6,996 runs on Friday as India tightened the screws on the tourists.
A victory for India, already one up in the three Tests, will see them beat the record of 10 straight home series wins they share with Australia.
Former India captain Sunil Gavaskar raised questions about the security arrangements at the MCA Stadium in Pune after a fan entered the playing field and managed to reach the wicket.
On the third day of the Test, the fan managed to breach the security cover before going up to India batsman Rohit Sharma, who took a fall as the spectator ran up to him.
Gavaskar, who was on commentary duty at that time, said it could have been a lot worse.
"These incidents happen because the security staff are not watching the crowd but are watching the match. This has been a perennial problem in India. The security is not there to watch the match for free. They are there to stop such interruptions from happening," Gavaskar said.
"I say put the camera on the security and check whether they are watching the match or the crowd. This is a dangerous security issue which is what you are there for, to make sure no one goes into the ground. Anyone can cause damage to a player. It has happened in the past, why take a chance," he added.