Sri Lanka took three late wickets as they tightened the screws on Australia in the second Test in Galle on Friday after setting the tourists a daunting target of 413 to save the series.
At the end of an action-packed second day, which saw 21 wickets tumble and a hattrick from Sri Lanka's Rangana Herath, Australia were 25 for three in their second innings – still 388 runs short of their target.
David Warner was unbeaten on 22 while skipper Steve Smith will resume on Saturday on one as the tourists face an uphill struggle to avoid an embarrassing loss within three days at the Galle International Stadium.
Although Mitchell Starc took six wickets as Australia restricted Sri Lanka to 237 in their second innings, the tourists were effectively undone in the first session of the day when they were skittled out for 106.
It was their lowest total in 28 Tests against Sri Lanka, who are on a high after winning last week's first Test in Pallekele. Victory in Galle would ensure that the Sri Lankans will win the three-match series with a game to play.
The 38-year-old Herath was the star performer after picking up only the second Test hattrick by a Sri Lankan.
Australia, who resumed at their overnight score of 54 for two, struggled throughout the morning session against both Herath and his fellow spin bowler Perera, the duo sharing eight wickets between them.
Off-spinner Perera bowled overnight batsman Usman Khawaja in his second over of the day, before Herath took his first wicket by clean bowling the Australian skipper Steven Smith.
But it was Herath's seventh over of the innings which proved decisive as he dismissed Adam Voges, Peter Nevill and Starc off consecutive deliveries to put Australia on the mat.
Only Mitchell Marsh, who was the last man out for 27, offered much resistance for the Australians during the morning's play.
The visitors also struck early in the Sri Lankan second innings as the paceman Starc bowled his heart out on a flat pitch. The left-arm paceman took six for 50, but the Sri Lankans were still able to set what should be a match-winning target.
Dilruwan Perera was the top scorer for Sri Lanka with 64 and he received good support from his skipper Angelo Mathews who followed up his half-century in the first innings with 47.
Australia's response got off to a dreadful start when Joe Burns became Herath's fifth victim of the day in the opening over of the Australian second innings.
And the decision to send in Nathan Lyon as a night-watchman backfired when he was bowled for a duck before Usman Khawaja followed him back to the pavilion one ball later.
Australia, the world number one team, had only ever lost one Test against Sri Lanka before the current series. The final match is due to be held in Colombo from August 13.