Ashwell Prince and Mark Boucher repelled early Bangladesh pressure with a record sixth-wicket stand to take South Africa to 357 for five at stumps on the second day of the second Test on Thursday.
Bangladesh had reduced the hosts to 134 for five midway through the second session but Prince and Boucher replied by adding 223 runs in a three-and-a-half hour spell.
Their unbeaten partnership beat South Africa's previous sixth-wicket record of 200 scored by Graeme Pollock and Tiger Lance against Australia in Durban in 1970.
Both batsmen scored centuries - Prince 115 and Boucher 102 - as Bangladesh's bowling became steadily more mediocre through a hot afternoon.
The compact Prince scored fluently to collect 16 fours and a six off 160 balls, while wicketkeeper Boucher's 162-ball innings was his first century since scoring 122 not out against the West Indies in Cape Town in January 2004.
After Bangladesh's first innings of 250, left-arm spinner Shakib Al Hasan roared through the middle-order to put South Africa in trouble.
South Africa were 192 for five at tea, as the visitors threatened to make a mockery of captain Graeme Smith's comments before the Test that he had seen no improvement in Bangladesh cricket since their introduction to the Test arena in 2000.
Shakib burst through the defences of Jacques Kallis, whom he bowled for 24, and Hashim Amla with excellent arm balls and then had AB de Villiers stumped for a duck two deliveries later as South Africa crashed from 112 for two to 134 for five.
De Villiers' dismissal ended a world record sequence of 78 innings before his first duck, the batsman rushing down the pitch to his second ball.
Amla was caught bat/pad by Imrul Kayes for 71, his wristiness and sweet timing giving rise to 10 fours off 140 deliveries.
Bangladesh removed Smith 35 minutes into the day's play when Mahbubul Alam won an lbw appeal against the South African captain and leading run-scorer in test cricket this year.
Smith's innings ended on 27, after he and Amla had taken South Africa from their overnight score of 20 for one to 47.
Mahbubul was accurate in the morning session but was punished thereafter to finish the day with one for 64 in 20 overs, while Shakib had three for 77 in 23 overs.