A stunning century by emerging Sri Lankan strokemaker Kusal Mendis ended early on day four, but Australia still faced a daunting task if they were to claim victory in the first Test.
Resuming with a lead of 196 and four wickets in hand, the hosts pushed that advantage to 267 before they were dismissed for 353 after lunch at the Pallekele Stadium.
The Australians have only once successfully chased more than 200 on the sub-continent, against Bangladesh in Dhaka in 2006. 
That challenge only grew when, in the second over, David Warner stepped down the wicket to left-arm spinner Rangana Herath and was bowled, having played over the top of the delivery. It completed a miserable match for the Australian vice-captain, who was dismissed for a duck in the first innings, having only recently proven he had recovered from a broken finger.
Mendis began the day on 169 but managed only seven more runs when he prodded at a wide delivery from intimidating paceman Mitch Starc and feathered an edge to gloveman Peter Nevill.
Australia had wanted to take the second new ball late on Thursday but was denied this when Mendis and Dilruwan Perera accepted an offer from the umpires to leave because of poor light.
The tourists have been destructive with the new ball through this match, and so it proved when Mendis' fine knock came to an end - but not before he had posted the highest Test score on this ground.
It was also the second-highest knock by a Sri Lankan against Australia, falling just short of Kumar Sangakkara's 192 in Hobart almost nine years ago.
The son of a three-wheeler driver in Colombo, and with only one first-class ton to his name before this match, Mendis appears set to be a long-term plank of Sri Lanka's rebuild.
Mendis was hailed on Friday as the next-generation Mahela Jayawardene, the former champion Sri Lankan captain, by another local great, Aravinda de Silva.
Jayawardene, for his part, had said on social media that the hosts needed to add 75 more runs to their overnight score "to win this Test". They would add 71.
Having torpedoed the hosts for 117 on the opening day, a loss here would be a major psychological blow for the Australians, who had enjoyed an extended warm-up for this series. Their own poor first-innings let the hosts back into the game, and the home team capitalised. With a spin-friendly wicket of Galle awaiting next week, followed by what typically is a flat deck in Colombo, Australia faces a major fight to improve their recent poor record on the sub-continent.
It was a delayed start to the day because of the threat of rain and, when play finally began, it lasted only 50 minutes before rain fell.
Once the clouds dispersed, Josh Hazlewood was again in the action when he had Perera playing across the line, and trapped lbw.
Starc dismissed Lakshan Sandakan in comical fashion. Sandakan backed away to leg, only for Starc to follow him, and the ball to rebound and trickle onto his stumps.
Sri Lanka's fightback ended when Herath was brilliantly caught by substitute fieldsman Moises Henriques off Hazlewood.
But Herath had thumped six boundaries, providing crucial runs and extending Australia's agony.


SCOREBOARD
Sri Lanka: 1st innings 117
Australia: 1st innings 203
SRI LANKA: 2nd inningsR M B 4s 6s
K Perera lbw Starc 4 10 5 0 0
K Silva lbw O'Keefe 7 59 32 0 0
D Karunaratne lbw Starc 0 2 3 0 0
K Mendis c Nevill b Starc 176 319 254 21 1
A Mathews c Burns b Lyon 9 54 31 0 0
D Chandimal lbw Marsh 42 117 100 4 0
D de Silva c Khawaja b Lyon 36 80 62 3 0
D Perera lbw Hazlewood 12 51 22 2 0
R Herath c Henriques (sub) b Hazlewood 35 60 34 6 0
L Sandakan b Starc 9 6 7 2 0
N Pradeep not out 10 21 12 2 0
Sundries (1b, 12lb)13
TOTAL: 353
FALL: 6 (K Perera), 6 (Karunaratne), 45 (Silva), 86 (Mathews), 203 (Chandimal), 274 (de Silva), 290 (Mendis), 314 (D Perera), 323 (Sandakan), 353 (Herath). BOWLING: M Starc 19-4-84-4, J Hazlewood 18.4-3-59-2, S O'Keefe 16.2-3-42-1, N Lyon 27-2-108-2, D Warner 1-0-10-0,
A Voges 1.4-0-3-0, M Marsh 9-1-33-1, S Smith 1-0-1-0.
BATTING TIME: 399 minutes. OVERS: 93.4.
AUSTRALIA: 2nd innings R M B 4s 6s
J Burns not out 8 19 17 1 0
D Warner b Herath 1 5 4 0 0
U Khawaja not out 11 12 9 2 0
Sundries 0
TOTAL (for one wicket) 20
FALL: 2 (Warner) BOWLING: N Pradeep 3-0-16-0, R Herath 2-0-4-1.
BATTING TIME: 19 minutes. OVERS: 5.