South Africa were struggling to avoid a heavy defeat in their opening tour match in Australia after a late batting collapse on Tuesday.
The Proteas, preparing for their three-Test series against Australia starting next week, lost eight wickets for the addition of just 88 runs in the final session to slump to 25 for two in their second innings against Western Australia.
The visitors were ordered to follow on after collapsing to be all out for 179 in the first innings in reply to the home team's 391-8 at the WACA in Perth.
They lost AB de Villiers and Herschelle Gibbs cheaply to end the second of three days still 187 runs behind a Western Australia team that is yet to win a match in this season's domestic state championship.
Western Australia declared their first innings early after rain washed out most of the morning session.
Medium-pacer Shawn Gillies (3-41) capped his first-class debut by ripping through the South African top order before Beau Casson (4-21) and Ben Edmondson (3-48) combined to polish off the tail.
South Africa had made a promising start when De Villiers and Jacques Rudolph put on 71 for the first wicket when the wheels suddenly fell off.
Gillies made the breakthrough in his first over when he bowled De Villiers for 27 then removed Rudolph four balls later, caught at point for 43.
He also had Ashwell Prince caught on the boundary for four and when Edmondson bowled Gibbs for 25 the South Africans were already in trouble at 116-4 at tea.
Things went from bad to worse for the visitors in the final session as Edmondson and Casson cleaned up the last six wickets for 55 runs then struck twice more in the second innings before the close of play.
The South Africans are due to play a one-day match against an invitational side on Friday and another three-day game against Western Australia next week before the first Test starts at the WACA on December 16.