In reply to South Africa's 242, Australia were 181 for four with Adam Voges not out 10.
Opener Shaun Marsh fell to the last ball before lunch, trapped lbw by Vernon Philander and unsuccessful with a decision review.
Australia were in total control at 158 for none, but then they lost four wickets for just 23 runs.
The game turned when left-hander David Warner fell for 97, caught at first slip by Hashim Amla from the bowling of Steyn.
Warner appeared certain to score his fourth Test century at the WACA Ground, and his dismissal sparked a remarkable period of play.
Just eight runs later, Steyn left the field mid-over, after appearing to reinjure his troublesome right shoulder in an around-the-wicket delivery to Usman Khawaja.
One run later, Khawaja joined Warner back in the pavilion when he was clean-bowled by young paceman Kagiso Rabada for four.
South African hopes were further boosted when Australian captain Steve Smith was the victim of a highly contentious lbw decision for a duck.
Smith advanced well down the wicket to debutant spinner Keshav Maharaj and was struck on the knee roll. He was visibly shocked to be adjudged out by veteran umpire Aleem Dar.
The Australian skipper called for a decision review, which showed the ball just clipping the outside of the stumps, which is out under new rules introduced recently.
Steyn hurt his shoulder with the fourth ball of his 13th over, having been by far the most menacing of the South African bowlers.
The 33-year-old missed several months of cricket earlier this year with the injury and he left the WACA to have scans.