Sri Lanka took three late wickets as they tightened the screws on Australia in the second Test in Galle 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 hat-trick 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 the Sri Lankans 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 hat-trick 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.
"It was a good achievement. I have only taken a hat-trick only playing for school and not anywhere else. So, very pleasing to do that against the number one-ranked team," a smiling Herath told reporters.
Herath, the only member from Sri Lanka's 1-0 series win against Australia in 1999, said winning the rubber with the current side would be more relishing.
"First Test is always special. At that time, we had some big stars. Arjuna (Ranatunga), Aravinda (de Silva) and Sanath (Jayasuriya).
"But we have not much experience here and I am really pleased with what I have done," he added.
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 Lanka 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.
"After 17 years we are on the verge of winning the series. I am lost for words... winning against the number one team is a big achievement," said Herath.
Dilruwan Perera top-scored 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.
"Disappointing. Full stop. Not up to international standars that performance today," Australian coach Darren Lehmann said Friday.
"Obviously still a long way to go, hopefully. But certainly we haven't played as we would have liked. Sri Lanka have played well and we haven't."
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.