Set a world record victory target of 458, South Africa finished eight runs short on 450 for seven after a day of tension and drama.
Du Plessis (134) and De Villiers (103) shared a fifth wicket partnership of 205 - a world record for a fifth wicket stand in the fourth innings of a Test match.
For much of the day, a draw seemed to be the best result that South Africa could hope for, but with De Villiers in particular batting with positive intent, the required run-rate was always below five runs an over.
With Indian captain Mahendra Singh Dhoni forced to set defensive fields, De Villiers was bowled with 56 runs required in 13.5 overs, attempting to run the ball down to third man but edging it into his stumps.
JP Duminy cracked a boundary off Mohammed Shami but was then bowled off an inside edge, attempting another drive.
Vernon Philander, who hit a half-century in the first innings, joined Du Plessis and pushed the score along while Du Plessis remained rock solid.
With 20 needed off four overs, Du Plessis pulled Zaheer Khan for four but was then run out by a direct hit from Ajinkya Rahane at mid-off as he attempted to retain the strike.
Du Plessis, who saved a Test with a century against Australia in similar circumstances on his debut in Adelaide last year, batted for 395 minutes, faced 309 balls and hit 15 fours.
South Africa settled for the draw but Dale Steyn hit the last ball of the match from Mohammed Shami for six to leave the hosts tantalisingly close.
Du Plessis and De Villiers came together before lunch and batted through the afternoon session with only minimal alarms on a pitch which played reasonably easily, although there was still some uneven bounce and deviation from a cracked surface.
The partnership was launched after Khan claimed his 300th Test wicket when he won a leg before wicket decision against Jacques Kallis, South Africa's senior batsman.
Kallis, who made 34, looked surprised when he was given out by umpire Rod Tucker. Replays showed the ball had come off an inside edge. In a series in which the decision review system (DRS) is not being used, it was the first major error made by umpires Tucker and Steve Davis.
Fast bowler Shami bowled Alviro Petersen in the fifth over of the day, after South Africa resumed at 138 for two, with Petersen failing to add to his overnight score of 76.
Petersen played a tentative defensive shot to a ball outside his off stump and was bowled off an inside edge.
Kallis, who was leg before wicket first ball to a full delivery from Ishant Sharma in the first innings, came within millimetres of suffering a similar fate to the first ball he faced from Shami. It was full and struck Kallis on the pads but umpire Steve Davis ruled correctly that it was just outside the line of leg stump.
Kallis, who failed to reach double figures in six of his previous seven Test innings, struck Shami through the covers for four in his next over to open his score but was then dropped by Cheteshwar Pujara at short leg, with the fielder getting his left hand to the ball but failing to hold a sharp chance.
After his initial struggles, Kallis batted with authority to score his 34 runs off 37 balls before he was given out.
At that stage there were 74.2 overs remaining and India were favourites to close out victory, but Du Plessis continued to play an anchor role, while AB de Villiers played positively.
The world record for a successful run chase is 418 for seven by West Indies against Australia in St John's in 2002/03.