South Africa 311 and 238 for 5 (Markram 84, De Villiers 51*) lead Australia 255 (Bancroft 77, Morkel 4-87, Rabada 4-91) by 294 runs
Scorecard and ball-by-ball details

This series was already a bubbling cauldron of toil and trouble. Not surprisingly, the addition of Cameron Bancroft's underpants to an already putrid mix could have results as unpredictable as eye of newt and toe of frog. Certainly it resulted in a stink on the third day in Cape Town, where half-centuries from Aiden Markram and AB de Villiers pushed South Africa's lead towards 300 and rendered Australia's task for the remainder of this Test very difficult indeed.

The morning had started with Australia nine wickets down and 66 runs behind, hoping to close the first-innings gap as much as possible. They added only 10 before Kagiso Rabada had Josh Hazlewood caught at slip to end the innings. By stumps, South Africa had turned their 56-run advantage into a 294-run lead, with five wickets still in hand. Australia will desperately need quick wickets on the fourth morning, and first they will have to find a way through either de Villiers, still at the crease on 51, or Quinton de Kock, who had 29, with South Africa's total on 238 for 5.

But the wickets and runs of the day were somewhat overshadowed by the events of the middle session, when the TV cameras appeared to show Bancroft holding a foreign object while working on the ball, and shortly afterwards he seemed to deposit the item down his trousers. The on-field umpires spoke to Bancroft but did not appear to take any action at the time, however it is certain to become the subject of heated debate in a series already full of controversy.

South Africa's second innings had started innocuously enough, although Australia rued a missed opportunity in the first over when Markram was put down at gully by Usman Khawaja off Mitchell Starc. The only South African wicket to fall before lunch was that of Dean Elgar, who had carried his bat for 141 in the first innings but here edged Pat Cummins to slip on 14, to provide Steven Smith with his sixth catch of the match.

Markram and Hashim Amla compiled a 76-run partnership that ended when Amla chipped a catch to Bancroft at cover off Cummins for 31, but all that did for Australia was bring the in-form de Villiers to the crease. He showed few signs of needing to get his eye in, slashing his way off the mark with a remarkable six over the off side off the bowling of Cummins. By the close of play, de Villiers had a 92-ball half-century and had done much to strengthen South Africa's already excellent position.

Markram had moved to a half-century from 91 deliveries and had struck 10 fours and two sixes by the time he fell tamely for 84 in the final over before tea, when he chipped a catch to mid-on off Starc. That lapse in concentration, which was also the umpteenth dismissal on the verge of a break in play during this series, robbed Markram of the opportunity to push for his second century of the series.

Faf du Plessis continued his struggle to have an impact in this series, trapped lbw to become the 299th Test wicket of Nathan Lyon. Du Plessis was adjudged not out on field, but if Australia's review looked little more than hopeful it proved to be well-judged, for the ball-tracking suggested du Plessis was far enough back that height was not an issue, and the ball would have crashed into the top of leg stump. His 20 was the highest score he has made in his past eight Test innings.

Temba Bavuma once again failed to get himself in, during what is his first competitive match since January, and his first match at first-class level since last year. On 5, Bavuma edged Hazlewood and was well taken at second slip by the substitute fielder Peter Handscomb, on at the time for Smith.

However, any hope the Australians had of finishing the innings quickly were dashed by de Kock and de Villiers, whose partnership by stumps was worth 37. Play ended early due to bad light, and the Bancroft incident looked set to dominate all the post-play discussions. But the hurly-burly is not yet done, the battle not yet lost and won, and the teams will arrive on day four with South Africa in a dominant position.