Dhawan put on 127 for the first wicket with Rohit Sharma (65) and 83 off 77 balls for the second with Virat Kohli (31) as overcast conditions at the toss made way for bright sunshine.
India slipped from 210-1 to 260-5, but an unbeaten 47 from 29 balls by Ravindra Jadeja steered the side past the 300-run mark.
Jadeja also starred in the field as he took the wickets of JP Duminy and Lonwabo Tsotsobe, ran out Peterson and caught de Villiers at mid-wicket.
"I think we were at least 25 runs short after losing so many wickets later in the innings," said Indian captain Mahendra Singh Dhoni. "But the boys fielded with plenty of aggression."
De Villiers said he was not unduly disappointed.
"We got ourselves into a great position to win the game with the bat," he said. "I am proud of the way we fought back through the day. We were above the run rate but lost wickets at the wrong times."
South Africa next play Pakistan in Birmingham on Monday, and India meet the West Indies at the Oval in London on Tuesday.
- AAP