Australia 106 (Warner 42, D Perera 4-29, Herath 4-35) and 25 for 3 (Warner 22*, Smith 1*) need another 388 runs to beat Sri Lanka 281 and 237 (D Perera 64, Starc 6-50)
Scorecard and ball-by-ball details

The second day in Galle finished as it started: with Steven Smith at the crease facing Dilruwan Perera. Australia would take that result if it meant a captain's innings, a double-century to drag his side back into the series. The reality was a world away from that, for in between Perera had taken five wickets and scored a half-century, Rangana Herath had claimed a hat-trick, 21 wickets had tumbled, and Australia had collapsed to their lowest ever Test total against Sri Lanka.

This was the day on which Sri Lanka made certain that they would lift the Warne-Muralitharan Trophy for the first time. It was not yet struck in 1999, the only other occasion on which they beat Australia in a series. Indeed, that was the only other occasion on which they beat Australia in a Test. In the first 33 years of Test cricket between the two countries, Sri Lanka won just a single game. They will now do so twice in a fortnight.

Australia were set 413 for victory, which would be the third-highest successful chase in Test history. Gettable, perhaps, for an in-form batting unit on a pitch to their liking, if everything fell their way. But this Australian outfit was demolished in the first innings for 106, on a turning surface against a quality spin attack. Australia have as much chance of winning this Test as they do of winning Olympic gold in baseball. And no, baseball is no longer on the Olympic roster.

By stumps, Australia were already 25 for 3 in their chase. Joe Burns had driven a catch to cover off Herath in the first over. Nightwatchman Nathan Lyon had poked a catch to silly point off Perera. And next ball, Usman Khawaja had watched an arm ball from Perera crash into his stumps. Dazed and confused, Khawaja offered no shot. His dismissal was emblematic of the day: Australia had no clue whether each ball from a Sri Lanka spinner would turn or not.

And so at the close of play, Smith walked off on 1, with David Warner on 22, and a Sri Lankan victory inside three days appeared all but certain. The afternoon consisted largely of Sri Lanka's batsmen frustrating Australia, growing their lead and humiliating their visitors further. Herath and Perera, who tormented Australia with the ball at either end of the day, scored nearly as many runs between them as Australia did in the first innings.

The story of this day was the first session, in which Australia lost eight wickets for 52 runs. The cricket felt like it was played in fast-forward and at times the action was so comical that the Benny Hill theme would have been appropriate. The pitch was turning, but it was far from a poor surface. But it was as if Australia's batsmen had never seen spinners before. They simply wondered at this mysterious slow form of bowling.

Sri Lanka's spinners attacked the stumps and built persistent pressure. Herath turned some and skidded others on. So did Perera. Lakshan Sandakan didn't, but that was only because all the work was done already. Such was the annihilation that he came on only to collect the final wicket, and finished with 1 for 0 from two deliveries.

Resuming at 54 for 2, Australia failed to survive even 20 overs of the day's play. Australia's 106 was their lowest total ever against Sri Lanka, and their lowest total in Asia for nearly 12 years, since they were skittled on a Mumbai dustbowl for 93 back in 2004. Herath finished with 4 for 35 and Perera with 4 for 29.

Khawaja fell in the third over of the day when he missed an arm ball from Perera and was bowled for 11 - at least he played at this one - and Smith departed next over when he played back and tried to cut a slider from Herath. He too was bowled. So much for the "play straight" mantra Australia had tried to instil on this tour.

Then came Herath's hat-trick: Adam Voges drove on the up to cover, Peter Nevill was trapped lbw by another slider, and Mitchell Starc completed the trio when he leaned forward and was hit on the pad first ball. Starc was given not out but Angelo Mathews asked for a review, out of nothing but hope. He was as surprised as anyone that the not-out decision was overturned.

Only one other Sri Lankan had ever taken a Test hat-trick: Nuwan Zoysa, who achieved the feat against Zimbabwe in Harare in 1999-2000. Herath's wickets left Australia at 80 for 7 and in serious danger of failing to reach triple figures. In fact, they still needed two runs to avoid the follow-on, which appeared by no means a certainty.

They did scrape past that mark but soon Lyon was caught in close off Perera and Josh Hazlewood edged to slip off the same bowler. Mitchell Marsh, at the other end while so much carnage was unfolding around him, slammed a couple of sixes to push the score past 100, but was caught at long-off when he tried for another off Sandakan's second ball.

Sri Lanka lost three wickets of their own before lunch - 11 wickets fell in the session - but already their lead was healthy. Perhaps their only concern at the moment is the consistent failure of their openers, for again Kaushal Silva and Dimuth Karunaratne failed to reach double figures. Karunaratne was the first of six wickets for Mitchell Starc, who deserves commendation for his hard work, gaining rewards through reverse swing, speed and persistence.

Starc finished with match figures of 11 for 94, the finest by any Australian in Sri Lanka, and second only to Mohammad Asif for visiting fast bowlers in the country. Not since Geoff Dymock claimed 12 against India in Kanpur in 1979 had an Australian fast bowler been so successful in a Test match in Asia.

But where Sri Lanka's spinners were important, Australia's were impotent. Out of desperation, Lyon resorted to bowling legbreaks as Sri Lanka's innings wore on, and Jon Holland was treated with the disdain Sri Lanka's batsmen might dish up to a bowler from Holland. Eventually Australia bowled the Sri Lankans out for 237. The figure was almost irrelevant, though a complete Sri Lankan capitulation might almost have made a game of it.

Instead, Kusal Perera contributed 35, Mathews scored a brisk 47, Dilruwan Perera compiled 64, Herath chipped in with 26, and Dhananjaya de Silva managed 34. It was enough to set Australia 400 plus. It was enough, after Australia's morning collapse, to decide the series.

Brydon Coverdale is an assistant editor at ESPNcricinfo. @brydoncoverdale