Hastings' career-best 6 for 45 helped Australia take an unassailable 3-1 lead in the five-match series.
Aaron Finch hit the equal-fastest ODI half-century by an Australian, joining Simon O'Donnell's 18-ball mark in 1990.
John Hastings claimed six wickets before Aaron Finch and George Bailey's attacking half-centuries powered Australia to a series clinching six-wicket win over Sri Lanka in the fourth one-day international in Dambulla on Wednesday.
Australia rode on Finch's 19-ball 55 and an unbeaten 90 from Bailey to chase down 213 in 31 overs and take an unassailable 3-1 lead in the five-match series.
Earlier Hastings career-best bowling figures of 6-45 helped bowl out Sri Lanka for 212 after electing to bat first despite Dhananjaya de Silva's fighting 76.
It was Finch's 19-ball 55 that gave Australia a rocket start against a Sri Lankan attack that missed skipper Angelo Mathews' medium pace after the allrounder hurt his calf while batting.
Finch, who equalled the record for the fastest fifty by an Australian, struck eight fours and three sixes as he carted the Sri Lankan spinners to all parts of the ground.
Left-arm spinner Sachith Pathirana's triple strike in the space of five deliveries checked the visitors' surge but only for a brief while.
Pathirana got the wickets of danger man Finch and Usman Khawaja for nought in his opening over of the innings. He then bowled skipper David Warner for 19 on the first ball of his next over.
Bailey, who registered his 21st ODI fifty, carried the momentum forward as he anchored Australia's chase with his 85-ball knock, laced with 11 fours and a six.
He got the perfect partner in Travis Head, who scored 40, as the duo put on 100 runs for the fourth wicket.
Head was trapped lbw off Dilruwan Perera but Matthew Wade, who remained unbeaten on eight, joined Bailey at the crease to hit the winning six.
The victory comes as a welcome relief for the visiting side after it suffered its first series whitewash against Sri Lanka in the three Test matches.
The fifth and final match of the ODI series is scheduled for September 4 in Pallekele.