Dhananjaya de Silva scored a magnificent maiden Test century and Dinesh Chandimal also frustrated Australia after the tourists had ripped through Sri Lanka's top order on day one in Colombo.
Early strikes from Mitchell Starc (3-47) and Nathan Lyon (2-72) had Sri Lanka in dire straits at 26-5 in the third and final Test after Angelo Mathews had won the toss and elected to bat first.
De Silva (116 not out), playing only his third Test, and Chandimal (64no) dug Sri Lanka out of a hole with a brilliant unbroken sixth-wicket stand of 188 to take them to 214-5 at stumps.
Peter Nevill was unable to take a difficult chance to dismiss de Silva when he was on 73 and Shaun Marsh also put him down as Australia, aiming to avoid a series whitewash, suffered more anguish on what has been a miserable tour.
It had all started so well for the tourists, who recalled Marsh and Moises Henriques at the expense of Joe Burns and Usman Khawaja, when the impressive Starc produced a devastating opening spell.
The left-arm quick had Kaushal Silva caught by Steve Smith at second slip without scoring and the captain held on once again when spinner Lyon, brought into the attack for only the sixth over, drew an edge from Kusal Perera (16).
Opener Dimuth Karunaratne (7) was given a send-off by Starc when an inside edge clattered into his stumps and Sri Lanka had lost four wickets for only five runs after the in-form Kusal Mendis and Mathews both fell for just one.
De Silva and Chandimal set about dragging Sri Lanka out of the mire, with the former successfully reviewing after being given out caught at bat pad before reaching double figures and also given not out following an Australia review when Jon Holland thought he was caught behind.
The increasingly composed De Silva dispatched Starc for three boundaries in an over and Australia wasted their second review after the number six was struck on the pads but Mitchell Marsh's delivery was sliding down leg.
Holland was holding his head after de Silva edged one that turned and bounced sharply, but wicketkeeper Nevill could not cling on to what would have been an outstanding catch.
Watchful vice-captain Chandimal rotated the strike well and brought up his half-century with a single off a frustrated Lyon, who failed with a big shout for leg before from the previous delivery.
De Silva, whose previous Test-best was 37, was given a standing ovation after hitting Smith for four to reach three figures for the first time at international level and had another life when Shaun Marsh spilled him at short cover.
Australia were unable to strike with the new ball as de Silva, who played some glorious drives, and the solid Chandimal put Sri Lanka in a promising position.