Matthew Breetzke and Ryan Rickelton survived the final over to remain unbeaten on 19 and eight, respectively.
SA's position is precarious despite the lead.
They have only six wickets remaining and still need to build a substantial fourth-innings target, with Australia's attack having already removed Ackerman and Bavuma after their important partnership.
Australia had started the morning on 330/4, with Josh Inglis and Alex Carey having already added 145 for the fifth wicket.
They extended that stand to 185 before SA finally found the breakthrough they needed.
Inglis completed his second Test century from 132 balls but fell for 102 soon afterwards when he edged Simon Harmer through to wicketkeeper Rickelton.
It ended an innings that had put Australia firmly in control and broke a partnership that had frustrated the Proteas for much of the previous day.
Harmer struck again four overs later to remove Carey for 80, with Aiden Markram taking the catch at slip.
The double breakthrough left Australia 379/6 and changed the momentum of the innings.
The Australian lower order offered resistance, but SA continued to chip away.
Pat Cummins was trapped lbw by Kagiso Rabada for a duck before Mitchell Starc was caught behind off Gerald Coetzee for 11.
Australia went to lunch on 411/8, with Cooper Connolly on 20 and Nathan Lyon on one, before SA wrapped up the innings shortly after the interval.