Set a stiff target of 458 for victory, the hosts rode on centuries from Faf du Plessis (134) and AB de Villiers (103) to very nearly pull off a sensational victory but in the end fell short by just eight runs.
In a riveting match, which saw fortunes fluctuating from one team to the other till the very end, both teams had chances of winning the game in the nerve-wrecking final session on a Wanderers track, which showed no signs of deterioration even on the final day.
South Africa sniffed a historic win on the back of their fifth-wicket partnership as they inched closer to the improbable target of 458 runs, which if achieved would have been the biggest ever successful run chase in Test history.
The highest successful run chase in Test cricket has been achieved by West Indies who scored 418 for seven to beat Australia in St Johns in 2003.
More From This Section
At one stage, it looked like the Proteas would romp home as they needed just 64 runs from the final 16 overs with six wickets in hand but Ishant Sharma bowled De Villiers and Mohamed Shami dismissed JP Duminy before Du Plessis' run out in 133rd over.
Plessis's knock came off 309 balls with 15 boundaries while De Villiers faced 168 balls and hit 12 boundaries.
It was a remarkable Test match and the Indians would feel that they let go a good opportunity to record a famous Test win on foreign soil particularly after the drubbing in the preceding ODI series.
The two teams will now travel to Durban, where the second and final Test will begin from Thursday.