A magnificent Dinesh Chandimal century proved to be in vain as Australia beat Sri Lanka by two wickets in Tillakaratne Dilshan's final one-day international to take a 2-1 series lead on Sunday.
Chandimal continued his rich vein of form with a majestic 102 after he was put down on 40 and veteran opener Dilshan made 42 in his ODI swansong, but Sri Lanka could only make 226 all out in Dambulla after Adam Zampa took 3-38.
George Bailey top scored with 70 and Zampa went through for the winning run after he was dropped as Australia got home with four overs to spare to edge back in front in the five-match series despite being reduced to 44-3.
Dilshan was unable to end his ODI career with a win, but the flamboyant 39-year-old struck five boundaries in an entertaining knock and also took a fine catch in his 330th and last appearance in the 50-over format.
The crowd rose to Dilshan, who bowed as he walked off after slapping a full toss from spinner Zampa straight to Bailey at midwicket following early wickets for Mitchell Starc (2-42) and Josh Hazlewood (1-51).
Chandimal steadied the ship, rotating the strike well and making the most of a life after he was put down by stand-in captain David Warner at gully off Hazlewood.
The outstanding Chandimal picked out the bad balls, finding the boundary seven times, and punched the air after bringing up his century with a drive through the covers for a single.
Zampa was the pick of the bowlers and James Faulkner (2-44) ended Chandimal's classy knock in the final over to leave Australia needing 227 to win.
Dilshan took a good catch for captain Angelo Mathews (2-30) at point off to see the back of Warner (10) before Aaron Finch (30) was given out lbw and opted not to review when replays showed Amila Aponso's delivery was missing leg stump.
Australia were in trouble on 44-3 when Shaun Marsh (1) fell cheaply, but Travis Head (36) and Matthew Wade (42) made contributions and Bailey's composed knock frustrated Sri Lanka.
The tourists slipped from 187-4 to 222-8, but sealed victory when Dilruwan Perera dropped Zampa and he scampered through for a single.