PORT ELIZABETH, South Africa (AP) — Australia came back with five wickets in the final session to stop South Africa's momentum and hold the home team to 263-7 and a slim lead of 20 runs by stumps on day two of the second test on Saturday.

South Africa was 153-2 at tea — with two batsmen on half-centuries — and heading for a significant first-innings lead at St. George's Park until Mitchell Starc bowled Hashim Amla with a swinging yorker on the fourth ball of the last session to start Australia's comeback.

Amla was out for 56, opener Dean Elgar followed next over for 57, and allrounder Mitchell Marsh picked up two wickets as Australia's bowlers went on a run of four wickets for 28 runs after tea.

"We got our rewards late in the day," Marsh said.

AB de Villiers held South Africa together until stumps with 74 not out from just 81 balls, a free-flowing innings with 14 fours that made batting look much easier than it really was on a pitch offering reverse swing for Australia's four pacemen.

South Africa is ahead but its position is not as strong as it was hoping for after a good start. That replicated Australia's first innings, when the tourists were 161-3 and 243 all out in a similar late slide.

Even though Elgar and Amla put on 88 for South Africa for the third wicket, that stand took nearly 3 1/2 hours and 278 balls. The Australians pushed hard to break it, and the two South Africans responded with determined defense to stay out there.

Amla was twice given out lbw and twice overturned the decision using video review, surviving on 7 and 40.

It was the kind of intriguing battle out in the middle that observers hoped for from this four-test contest before it was given a bitter taste that still lingers by an off-field confrontation between Australia's David Warner and South Africa's Quinton de Kock in the first test.

"Today was a tough day of test cricket and those people who are test-match lovers would appreciate the skill of the bowling and, especially when AB was batting toward the end, the skill of the batting," Amla sad.

On Saturday, there were more issues to take attention away from the cricket.

South Africa fast bowler Kagiso Rabada was charged for bumping his shoulder into Steve Smith when he dismissed the Australia captain on the first day of the match. And two South African cricket officials face internal disciplinary procedures after they were photographed smiling with a group of fans who were wearing masks aimed at taunting Australia vice-captain Warner and his wife, who is with him on tour.

South Africa lost just one wicket in the first session, nightwatchman Rabada for 29, and no wickets in the second session, before the late surge from the Aussie quicks.

Starc bowled Amla and Josh Hazlewood had Elgar caught behind eight balls later. Marsh trapped South Africa captain Faf du Plessis and Theunis de Bruyn lbw in successive overs.

Offspinner Nathan Lyon also made his presence felt with the wicket of de Kock for 9. Lyon removed de Kock with a wonderful, flighted delivery that turned past the bat to knock back off stump.

Rabada was the chief destroyer in the Australia first innings with 5-96, including a burst of 5-13 off 18 balls. But his participation in the remainder of the series is in doubt.

Rabada was charged on Saturday morning by match officials for misconduct after the shoulder bump on Smith, and faces a two-test ban if found guilty of deliberate physical contact. That would see South Africa's best fast bowler miss the last two tests of the series. Rabada claimed the contact was unintentional and will have a disciplinary hearing on Sunday.

Rabada's is the fourth player disciplinary case of the series so far after Australia's Lyon and Warner and South Africa's de Kock were all found guilty of bringing the game into disrepute in the first test in Durban, where Australia won by 118 runs.