Pujara, 35 not out off 42 balls, and Rahane (11) resume on day three, with both needing solid knocks to not only help India to set South Africa a daunting last innings target but also to try and retain their places in the team after a run of poor form.
India are chasing a first ever series victory in South Africa and lead 1-0 after their 113-run opening-test victory.
Thakur, 30, posted career best figures of 7-61 -- the best return by an Indian bowler in a test against South Africa -- and single-handedly removed the home top order after South Africa resumed the day on 35-1
Keegan Petersen and Temba Bavuma scored half centuries in the home team’s reply to India’s 202 after the tourists had won the toss on Monday and elected to bat.
Thakur broke South Africa’s early resistance some 90 minutes into the day’s play when he had Dean Elgar caught behind for 28 after the home skipper had initially held off an impressive early barrage of hostile bowling.
Petersen brought up his first test half century but then followed his captain back to the dressing room when he was caught in the slips off Thakur for 62.
Rassie van der Dussen went cheaply off the last ball of the first session, with an inside edge, although television replays suggested the ball might have fallen short before being claimed by India wicketkeeper Rishabh Pant.
But the umpires determined there was no conclusive evidence that the catch fell short and the dismissal stood.
Bavuma and Kyle Verreyne put on a 60-run partnership after lunch before Verreyne was trapped leg before wicket for 21.
Thakur then bagged his fifth wicket when he had Bavuma snagged as he played a loose shot at a ball going leg side and was out for 51.
Thakur also took the last two wickets after the South Africa tail wagged, delivering potentially precious runs as the Wanderers wicket is expected to increasingly favour the seamers as the test progresses.