The visitors, who won the first match after scoring a world record 263, rode on opener Glenn Maxwell’s 29-ball 66 to chase down their 129-run target with 13 balls to spare.
Earlier Aussie bowlers James Faulkner and Adam Zampa claimed three wickets each to restrict the hosts to 128 for nine despite Dhananjaya de Silva’s fighting half-century.
Dilshan, who quit the one-day format in the middle of the five-match series which Sri Lanka lost 1-4, scored just one off three balls in his final international game but took two wickets to add drama to Australia’s chase.
The 39-year-old Dilshan, who participated in 87 Tests, 330 ODIs and 80 T20s, was given a standing ovation by a raucous home crowd as he ended his 17-year-long glittering career.
However the inventor of the “dilscoop”, the cheeky paddle shot played over the wicketkeeper’s head, did not have a chance to execute the audacious stroke.
“We all know Dilshan is a legend in the cricket world. He is a match-winner and a game-changer,” Sri Lankan skipper Dinesh Chandimal said of his teammate.
“He was my first one-day and Test captain, lucky to captain him in his last game. Thank you Dilshan. My team and I wish you all the best for the future.”
Maxwell, fresh from his unbeaten 145 off 65 deliveries on Tuesday, once again turned the spotlight on himself after equalling an Australian record for the fastest T20 fifty in 18 balls.
“To mention Glenn Maxwell, the way he played in the last game and this game was phenomenal,” Australia captain Warner said of his destructive opener who received the man of the match and the series award.
The 27-year-old batsman, who put on a 93-run opening stand with Warner, was bowled by leg-spinner Seekkuge Prasanna after hitting seven fours and four sixes.
Left-arm spinner Sachith Pathirana struck twice in the 10th over of the innings to get Moises Henriques and Warner, who scored 25, trudging back to the pavilion.
Faulkner’s run out in the very next over gave Sri Lanka a scent of a turnaround as Australia suddenly found it difficult to get the remaining runs.
Dilshan then trapped Usman Khawaja lbw with his wily off-spin and got the wicket of Matthew Wade, who scored 14, in his very next over as Australia slipped from 93 for no loss to 120 for six.
Travis Head, who remained unbeaten on nine, hit the winning runs to help Australia finish the two-month long tour on a high after the visitors suffered their first series whitewash in the three Tests.
“It is a massive achievement for our one-day boys. The boys came here with high hopes and expectations for the number one team in the world. Credit to the bowlers,” said Warner.
Bowlers day out
It was the bowlers who made it happen for the visitors after Sri Lanka won the toss and elected to bat first at the R Premadasa Stadium.
Medium-pacer John Hastings struck first with the wicket of Dilshan who edged a wide delivery to give away a catch to Warner at slip.
Kusal Perera and de Silva, who scored 62 off 50 balls, tried to counter the Aussie bowlers by hitting a few boundaries in the first six overs of powerplay with only two fielders allowed outside the 30-yard circle.
The left-handed Perera, who scored an 18-ball 22, fell to Faulkner as Warner took a superb diving catch at mid-on to check the Lankan surge.
Faulkner took another wicket in his second over to get Chandimal caught and bowled for four.
Zampa and Hastings soon took over to rattle the Sri Lankan middle-order as wickets fell at regular intervals.
De Silva, whose defiant knock was laced with five boundaries, kept up the fight until the final over when he got out to Mitchell Starc.