De Kock (168 not out) and Amla (110 not out) put on an unbeaten 282 to overhaul Bangladesh's 278 for seven with 7.1 overs to spare.
The South African openers overshadowed the feat of Mushfiqur Rahim, whose 110 not out was the first century by a Bangladesh batsman against South Africa in any international match.
Bangladesh's total was their highest in one-day games against South Africa.
Mushfiqur's innings came with a price. He appeared to suffer a hamstring injury and he watched the De Kock-Amla partnership from the players' balcony, adding to injuries which kept two other key players, Tamim Iqbal (thigh) and Mustafizur Rahman (ankle) out of the match.
Also Read
"These things happen in cricket. You can't blame anything."
Mashrafe said that although Bangladesh had posted a good total, "we knew we had to take wickets. If you can stop the runs at both ends the pressure will bring wickets. But we couldn't apply pressure."
South African captain Faf du Plessis praised what he described as another "dominating" performance. "As a team you want to be ruthless.
"Today was a very, very good example of that. When you're bossing the game and you are 150 for no wicket it's easy to throw wickets away, but the guys are hungry to put in massive performances."
Mushfiqur's fifth one-day century was greeted with rapturous applause by hundreds of Bangladeshi supporters. He made his runs off 116 balls with 11 fours and two sixes. He shared successive partnerships of 59 with Shakib Al Hasan, 69 with Mahmudullah and 42 with Sabbir Rahman for the third, fourth and fifth wickets.
Shakib made a quiet return after resting during a two- match Test series in which Bangladesh were heavily defeated. He made 29 and conceded 48 runs in eight overs. But he became only the fifth player to complete the one-day international 'double' of 5000 runs and 200 wickets.
Disclaimer: No Business Standard Journalist was involved in creation of this content