The Indian batter scored a maiden Twenty20 International century with a brilliant 107 from 56 balls in the game that was stopped for nearly half an hour by flying ants.
India were sent in to bat and amassed an impressive 219 for six in their 20 overs, boosted by the hitting of Varma and a sprightly 50 from 25 balls by opener Abhishek Sharma, Reuters reported.
South Africa were always behind in their chase in the face of some excellent spin bowling from Axar Patel (1-29 in four overs) and the wiles of seamer Arshdeep Singh (3-37), but a late flurry of runs got them close.
They managed 208 for seven in reply and trail India 2-1 in the four-match series with the final game to be played in Johannesburg on Friday.
Varma and Sharma put on 107 from 50 balls for the second wicket to lay the platform for the visitors as South Africa lacked discipline with the ball, conceding 10 wides and three no balls in the innings.
Varma reached his century from 51 deliveries as he struck eight fours and seven sixes.
The South African reply was an over old when the players were forced from the field for almost 30 minutes by a swarm of flying ants.
When they returned, India s spinners squeezed the run-rate in the middle overs, though the home side were kept in the contest by Marco Jansen s career-best 54 from 17 balls and Heinrich Klaasen s 41 from 22 deliveries.