De Kock, who handed over the white ball captaincy last March to Temba Bavuma, made 124 off 130 balls and made batting look easy on a pitch which offered some help to both seam and spin bowlers.
De Kock, who was named player of the match and player of the series, said of the pitch, "It wasn't flat at all. It was the kind of wicket where you were never really in."
India were on track for victory while Shikhar Dhawan (61) and Virat Kohli (65) were together during a second-wicket stand of 98 runs.
But Dhawan and Risabh Pant fell to Andile Phelukwayo in the same over and the odds swung firmly towards South Africa when Kohli was caught at cover off left-arm spinner Keshav Maharaj.
Suryakumar Yadav hit 39 off 32 balls but his dismissal, which was quickly followed by that of namesake Jayant Yadav, seemed to have settled the match.
Chahar, though, went for his shots, hitting two successive sixes off Dwaine Pretorius in the 44th over to reduce the target to 41 off 36 balls.
Chahar continued to attack the bowling and Ngidi and Sisanda Magala both bowled wides and Magala was no-balled as the South Africans lost their composure.
"We tried a couple of things that didn't come off," said Bavuma.
But Chahar played one shot too many and India lost their last two wickets quickly.
"We gave ourselves a real chance," said Indian captain KL Rahul.
"It is quite obvious where we have gone wrong. At times our shot selection has been really poor. We played well in patches but didn't keep the pressure on the opposition for long periods."