South Africa led by 236 runs on the first innings but did not enforce the follow-on.
Mushfiqur Rahim made a dogged 51 before being bowled by off-spinner Simon Harmer when he attempted a reverse sweep, a shot out of character at the end of a 136-ball innings.
Bangladesh were 210-7 at lunch and the last three wickets fell in 4.2 overs after the break, all to attempted big hits against Harmer and fellow spinner, left-armer Keshav Maharaj.