A remarkable innings from captain Dasun Shanaka won the third and final T20I for Sri Lanka against Australia in Pallekele on Saturday.

Australia had already sealed the series and looked on course for a whitewash until Shanaka (54 not out from 25 balls) started hitting boundaries at will to turn things around.

Aussie skipper Aaron Finch and David Warner got the tourists off to a strong start, hitting 43 within six overs before the former was bowled by Maheesh Theekshana for 29.

It was all looking too easy for Australia until a team hat-trick shook them in the middle of the innings, with Glenn Maxwell (16), Warner (39) and Josh Inglis (0) falling in consecutive balls.

Steve Smith (37 not out) and Marcus Stoinis (38) settled things back down, adding 48 before Stoinis was stumped by Kusal Mendis as the Aussies set a target of 177.

The hosts were in a promising position at 67-1, but once Pathum Nissanka (27) and Charith Asalanka (26) were gone, things looked bleak.

However, Shanaka all of a sudden went after every ball, and a partnership of 50 from 21 balls with Chamika Karunaratne (14 not out) set up a final over needing 19 runs for victory.

Kane Richardson bowled two wides, before two singles and three boundaries left Sri Lanka needing just one off the final ball, which arrived as Richardson sent down another wide.

Ultimate captain's innings from Shanaka

Heading into this game, many were doubting whether Shanaka should even be in the team. They are probably not questioning him now.

Shanaka hit five fours and four sixes as he almost single-handedly turned the game around, including a vital 14 from three balls in the final over. 

Hazlewood goes from hero to villain

Josh Hazlewood had been particularly stingy with his bowling, with figures of 2-3 after three overs.

However, his final over went for 22, with Shanaka hitting him for two fours and two sixes to inflate the experienced bowler's final numbers to 2-25 from four overs.