Bangladesh made 330-6 - their highest one-day total - with Mushfiqur Rahim scoring 78 and Shakib Al Hasan 75 in front of a passionate crowd strongly in their favour.
The pair put on 142 for the third wicket and, although both fell in the final 15 overs, Mahmudullah helped power his side to the highest total of the tournament with an unbeaten 46 off 33 balls.
South Africa, who were sloppy in the field, lost crucial wickets as they rarely threatened to complete the highest World Cup chase in history.