The Bangladesh wicketkeeper Mushfiqur Rahim rescued his side on the first day of the second and final test against South Africa in Centurion.
Rahim hit 65 in 86 balls and dominated a last-wicket stand of 56 as the visitors were bowled out for 250.
South Africa were 20 for one in reply at the close.
The keeper's rousing innings included nine fours and two sixes off fiery fast bowler Dale Steyn.
Last man Mahbubul Alam survived for an hour, scoring one not out in a partnership that lifted Bangladesh to a reasonable total.
The stand with Rahim was a last-wicket record for the team against South Africa.
Earlier, Zunaed Siddique struck 67 before a rampant Makhaya Ntini four for 32 removed him after tea thanks to a spectacular catch by Neil McKenzie in the gully.
South Africa are 1-0 up in the series.