Dilruwan Perera starred with bat and ball and Rangana Herath claimed a first-innings hat-trick as Sri Lanka battered Australia on day two of the second Test to close in on a famous series victory.
Australia crumbled from 54-2 to 106 all out - their lowest tally against Sri Lanka - in their first innings in Galle as 21 wickets fell on a dramatic day's play.
Herath became just the second Sri Lankan to take a Test hat-trick as Adam Voges (8), Peter Nevill (0) and Mitchell Starc (0) all fell to the veteran left-arm spinner, while Perera (4-29) also left the tourists in a spin.
Perera then added a brilliant 64 with the bat, while Angelo Mathews added an attacking 47 en route to Sri Lanka's 237 all out in the second innings.
Starc was again Australia's one bright note as the impressive paceman took 6-50 to make it 11 wickets for the match.
But it was little consolation as Australia then conceded three late wickets in their second innings with Perera snaffling a couple more scalps, leaving Steve Smith's men on 25-3, requiring 388 runs with three days to play.
Sri Lanka's spinners were undoubtedly on form in the first innings, but Australia's indecision also accounted for their downfall.
Dinesh Chandimal missed a stumping of Smith (5) in the second over of the day, but the captain was bowled by Herath shortly after Usman Khawaja (11) fell to Perera.
Herath then put his name in the history books with his hat-trick, first having Voges caught brilliantly by Dimuth Karunaratne and trapping Nevill plumb lbw, before completing the job by hitting Starc on the pads and successfully reviewing a not out decision.
Perera quickly dealt with the tail and Lakshan Sandakan - who bowled just two balls - accounted for Mitch Marsh (27), who had provided some resistance with three big sixes.
The morning action was not done, and Starc snared Karunaratne (7) and Kusal Mendis (7) after Josh Hazlewood (1-13) accounted for Kaushal Silva (5).
But Kusal Perera (35) and Mathews stretched the lead with a 48-run stand before the former was bowled by Nathan Lyon (2-80).
Mathews was in good nick and he found the boundary five times before his stumps were taken up by Lyon after a mistimed reverse sweep.
Perera set the tone for his innings with a huge six off Lyon that landed in front of the dressing room and he continued to find the boundary with regularity.
After surviving a review off Lyon, he went on to reach his second Test fifty with an inside edge past short leg.
Starc came back to rip through the lower order, including tearing up Perera's stumps, but Australia's misery was not over.
Herath struck in the first over as Joe Burns (2) prodded one to Dhananjaya de Silva at cover.
Nightwatchman Lyon (0) then stabbed one from Perera to Silva who took a fine catch low to his left, and Khawaja was bowled for a golden duck next ball.
Perera (2-9) failed to join Herath in taking a hat-trick, as David Warner (22 not out) and Smith (1 no) made it to the close, but Sri Lanka - who had only beaten Australia in Tests once before victory in the first match - are on the cusp of a series win.