Bangladesh replied with 249 all out, with 21-year-old seamer Andile Phehlukwayo claiming 4-40.
South Africa leads the three-match series 2-0, and now has the luxury of resting some of its big names for the final game on Sunday. Bangladesh is still searching for its first win over the Proteas on the tour, having also lost the test series 2-0.
Imrul Kayes made 68 for Bangladesh at the top of the order and Mushfiqur Rahim hit 60, but it wasn't enough as they chased South Africa's big score.
That big total was mainly down to the improvisation and power-hitting of De Villiers, who arrived with South Africa on 90-2 and left just over two overs from the end with his team 343-4.
He was part of century stands with Hashim Amla (85) and JP Duminy (30), and was the driving force of both, making 86 of the 136 runs he put on with Amla and 90 of the 117 he put on with Duminy.
De Villiers' last international was at the Champions Trophy in England in June. He skipped the test series against England and Bangladesh to rest and spend time with his family.
The break appears to have been well-timed for the 33-year-old former South Africa captain. He collected 15 fours and seven sixes on his way to the fourth highest score by a South African in ODIs. He was out caught in the deep only 12 runs short of Gary Kirsten's South African record of 188 not out.
De Villiers took only 68 balls to get to 100, and only 25 balls to go from 100 to 150, when he launched a flurry of sixes over square leg and midwicket.
Amla and Quinton de Kock (46) set South Africa up with a solid opening partnership of 90 but it was De Villiers' acceleration in the middle and late overs that took the game beyond Bangladesh.
Rubel Hossain was Bangladesh's best bowler with 4-62, including the wicket of De Villiers and two in two balls in the last over.