Jacques Kallis hit his second century of the match as Harbhajan Singh claimed seven wickets to bowl out South Africa for 341 in their second innings on Day 4 in the third Test, at Newlands, in Cape Town, on Wednesday.
India face a stiff task of having to score 340 runs on the final day to win their first ever Test series in South Africa on a pitch getting increasingly difficult for batting.
Kallis, battling a painful side strain, was unbeaten on a splendid 109 from 240 balls, inclusive of eight fours, following his sparkling knock of 161 in the first innings.
Harbhajan shone with the ball, claiming seven wickets for 120 in 38 overs, his 25th five-wicket haul in Tests, but the rest of the bowlers failed to make an impact.
Mark Boucher ended his poor run in the series as he hit 55 from 82 balls, adding 103 runs in 194 balls with Kallis.
Dale Steyn (32) and Morne Morkel (28) also made useful contributions with the bat as the last four wickets added 211 runs after South Africa were struggling at 130 six at one stage.
On Day 3, Dale Steyn claimed five wickets but Tendulkar's magnificent century -- his 51st -- helped India post 364 for a slender first-innings lead of two runs.
Tendulkar single-handedly kept India in the hunt as he scored 146, hitting 17 fours and two sixes in his 314-ball, 465-minute stay at the crease, before being bowled by Morne Morkel.
Steyn was lethal as he claimed five for 75 in 31 overs, most of the Indian batsmen unable to come to grips with his pace and movement.
Kallis's 39th Test century lifted South Africa to 362 in their first innings.It was Kallis's second century of the series as he stroked 161 from 291 balls.
S Sreesanth shone with the ball for India, claiming five for 114 in 29 overs, to trigger a lower order collapse.
The three-match series is locked 1-1.
Morning session: (69 runs, 28 overs, 3 wickets)
Harbhajan continued making most of the conditions as he claimed two early wickets to put India in the driver's seat.
The pitch seemed to have deteriorated considerably with a puff of dust coming off every time Harbhajan pitched on length on the footmarks. The off-spinner struck in his first over of the day when he again got one to turn sharply, trapping Petersen leg before wicket for 22.
South Africa seemed to panic on seeing the amount of assistance Harbhajan was getting; both Kallis and Amla were only resorting to sweep shots. That very shot caused Amla's downfall as he tried to play the sweep against Harbhajan but missed the ball and was bowled for two.
AB de Villiers was lucky to survive off the first ball he faced, as his inside edge fell away from the short leg fielder.
Despite that wicket and pitch doing a bit, both Kallis and de Villiers was looking to play only the sweep, including reverse sweep to try and unsettle Harbhajan.
Zaheer then made it worse for the hosts when he bowled de Villiers for 13. The right-hander tried to leave an incoming delivery but got an inside edge and saw his stumps uptooted as South Africa slipped to 98 for five in the 37th over.
Ashwell Prince got his first boundary in style, pulling a shot delivery from Zaheer through square leg.
Meanwhile, Kallis was battling pain as his hip injury started to get worse. He stretched forward to play a full delivery from Harbhajan but immediately collapsed and complained of pain around the hip area.
The veteran batsman must be relieved that he got a deserved break as the teams went back for lunch.
At lunch, South Africa were 121 for five in 44 overs, for a lead of 119 runs.
Kallis battled hard for 33 from 73 balls, while Prince was not out on 15 from 23 balls as South Africa looked under pressure to salvage the situation.
Harbhajan was superb with the ball as he claimed four for 41 in 17 overs, while Zaheer took one for 43 in 13 overs. They will be hoping to bundle out the South Africans under 200 because the pitch is getting difficult to bat with every passing over.
Post-lunch session: (91 runs, 28 overs, 1 wicket)
Kallis was again proving to be the thorn in India's flesh as he stretched South Africa's lead with a gutsy half-century. He was hampered a great deal because of his side strain but he never let his guard down.
Ishant gave India an early wicket after the lunch break when he dismissed Prince for 22. The left-hander drove Ishant for a delightful boundary through covers but seemed to have got carried away as he had a go at another wide delivery. But to his misfortune he hit it straight to Sreesanth, at point, who completed an easy catch.
But, in his next over, the Delhi pacer was hit for a couple of boundaries by Mark Boucher, through fine leg and covers respectively.
While Kallis was looking to stay at one end, Boucher was looking to get the scoreboard moving with singles and twos coupled with the odd boundary.
Kallis completed his half-century off 134 balls in grand style when he drove Ishant down the ground for a four. A few deliveries later, he was quick to punish through midwicket for another boundary in that over.
Harbhajan's threat was also easily negotiated by the duo as they played it late and managed to rotate the strike.
Sreesanth also tried all his varations including bowling from a short run-up but nothing fazed the two batsmen. Boucher pulled a short delivery from Sreesanth through square leg for his fourth boundary.
It turned out to be South Africa's session as they lost just one wicket, but were able to swell their lead beyond the 200-run mark.
At tea, South Africa were 212 for six in 72 overs, having stretched their lead to 210 runs with four sessions still left in the game and the pitch getting worse with every over.
Despite his injury, Kallis looked good for his second century of the match as he made 67 from 163 balls, while Boucher ended his run of poor scores as he scored 46 from 69 balls, the duo adding 82 runs for the seventh wicket.
Post-tea session: (129 runs, 30 overs, 4 wickets)
Kallis was the difference as India struggled to finish off the South African tailenders, the last four wickets adding as many 212 runs between them.
Kallis continued in the same vein after the tea break as he drove Sreesanth down the ground for a boundary in the first over of the session. He was lucky to survive a huge appeal for leg before wicket against Harbhajan as he attempted a sweep but missed and looked to be struck in front of the stumps, in the 74th over.
Boucher, meanwhile, completed his half-century off 74 balls with a single on the off-side off Harbhajan in the very next over. The two senior pros brought up the 100-run partnership for the seventh wicket in the 78th over to a loud cheer from the fans in the stadium.
Dhoni then brought on part-timer Tendulkar hoping for something to happen. And the move paid off as Tendulkar got the wicket of Boucher for 55. It turned out to be a freakish dismissal, as Boucher was trapped leg before wicket as he tried to play the pull shot but the ball kept low.
It ended a crucial partnership; Boucher and Kallis had anchored the team to safety, putting on 103 runs in 194 balls for the seventh wicket.
India took the second new ball straightaway in the 80th over and brought on Zaheer and Sreesanth into the attack, but it hardly mattered as the pacers lacked the killer instinct.
Dale Steyn came out determined to take on the bowlers at every possible opportunity. He showed his intent by pulling a short delivery from Sreesanth over midwicket for a four to a huge cheer from the crowd.
Kallis enjoyed a slice of luck when his edge against Zaheer between the second slip and gully for a four to move into the 90s.
In the next over, Steyn carted Harbhajan over the midwicket fence for a huge six. The duo brought up their 50-run partnership in just 69 balls as South Africa started to take control of the proceedings.
Harbhajan broke the partnership when he had Steyn caught at leg slip after a brisk 32 from 48 balls. His partnership of 54 from 77 balls for the eighth wicket with Kallis had slightly tilted the scales in South Africa's favour.
Kallis then hit his second century of the match off 228 balls with a single on the leg side off Harbhajan, in the 94th over. It was his 40th ton in Tests, overtaking Ricky Ponting and putting him in second place in the list of most century makers, behind Sachin Tendulkar (51).
Morne Morkel got off the mark in style when he cut a short ball from Harbhajan through point. In the next over, he slammed Ishant down the ground for another boundary to take his team past 300 in the 95th over.
The tall left-hander became Harbhajan's sixth victim of the innings when he holed out to long-on after scoring 28. Lonwabo Tsotsobe hit two boundaries in a row before Harbhajan had him caught in the same area to end with impressive figures of seven for 120 in 38 overs as the hosts were bowled out for 341 in 102 overs.
Kallis was left stranded on a brilliant knock of 109, having stayed at the wicket for more than six hours despite struggling with a side strain. He hit just eight fours in his 240-ball knock, which meant most of his runs came from singles and twos, despite that injury.
India need 340 to register their first ever series victory on South African soil on a crumbling pitch against the likes of Steyn and Morkel. India also were dealt a blow when Gautam Gambhir was unable to take the field after being struck in his arm while batting in the first innings.