Sri Lanka, who were 282 for six overnight, eventually managed to reach a total of 353, 267 runs ahead of the Australians
Australia faced an uphill struggle to save the first Test against Sri Lanka's rampant spinners after losing three early second innings wickets Friday while trying to chase down a formidable target of 268.
The tourists were precariously placed at 83 for three, with skipper Steve Smith unbeaten on 26, when bad light forced an early end to play for the fourth day running in Pallekele.
The world number one Test team still need another 185 runs for victory on the final day on Saturday, when Sri Lanka's trio of spinners will expect to capitalise on their early inroads against the tourists.
The hosts' leading left-arm spinner Rangana Herath struck in only the second over of the Australian innings when he bowled vice-captain David Warner for one.
Usman Khawaja started positively with three fours but he was ruled leg before wicket to off-spinner Dilruwan Perera when he attempted a sweep shot after making 18, leaving Australia reeling at 33/2.
Then the debutant Lakshan Sandakan joined the party with a ball that turned sharply and bowled opener Joe Burns, who had looked well set on 29.
One run later, first innings top scorer Adam Voges was ruled lbw to Perera for no score, but the batsman reviewed the decision successfully.
With the ball turning alarmingly, Smith and Voges then suppressed their urge to play attacking shots while keeping the scoreboard ticking over with some sharply run singles.
"It should be an interesting game if we get the full quota of 90 overs... We are still confident," Australia batting coach Stuart Law told reporters. "We saw Sri Lankans sweeping a lot. Our guys being a bit taller, sweep shot is a bit difficult so we try to use our feet," Law said.
Aussie rearguard, Smith's 54-ball innings has not featured any boundaries so far, while his partner Voges was batting in a similarly steadfast mood, reaching nine at the close of play off 25 deliveries.
Australia's struggles against the Sri Lankan bowlers further underlined the importance of Kusal Mendis' superb maiden Test century in what has been a low-scoring Test.
No other player on either side has passed 50. After starting the day unbeaten on 169, Mendis only managed another seven runs before he played away from his body to a full length delivery from Mitchell Starc to be caught behind by wicketkeeper Peter Nevill.
Starc was the pick of the Australian bowlers, finishing the innings with figures of four for 84. Herath and Nuwan Pradeep added 30 runs for the last wicket off 29 deliveries before the Sri Lanka innings ended after substitute fielder Moises Henriques took a spectacular catch at extra cover.
Sri Lanka, who were 282 for six overnight, eventually managed to reach a total of 353, 267 runs ahead of the Australians.
It was a remarkable turnaround after they conceded a first innings lead of 86 to the tourists, who were presented with the mace as the world's number one team on the eve of the match.
Much of their hopes of victory will rest on the shoulders of the 38-year-old Herath, who took four wickets in the first innings and has a reputation of cleaning up on the last day in home Tests. "Pleasingly, a few balls started to turn quite sharply before the players came off for bad light," said Sri Lanka's head coach Graham Ford.
"Hoping tomorrow that a few things will go our way, and we'll be able to press home and hopefully finish off with a big victory," he said. The second Test will be held in Galle from August 4-8 and the third in Colombo from August 13-17.