The opener was cagey in the early overs, before deciding to throw his hands at mystery spinner Theekshana and go after him at the top.
He hit 12 boundaries in his knock, going hard through the covers early and driving superbly as his innings went on.
And when he reached 99 Warner looked almost certain to end the longest century drought of his international career, which now sits at 48 innings across all formats.
But then the match swung violently in Sri Lanka’s favour, and toward their first bilateral one-day series win over Australia at home since 1992.
With Warner at the non-striker’s end Travis Head (27) was bowled by Dhananjaya, before Glenn Maxwell was trapped lbw by Theekshana next over.
And when Warner finally got the strike back Dhananjaya drew him off balance and beat his outside edge to have him stumped.
Cameron Green followed shortly after, before Cummins (35) and Kuhnemann’s late efforts.
The collapse will no doubt have evoked memories of the 2016 Test tour for the locals, when Australia struggled to combat the spin in the 3-0 series loss.
The good news for Australia on Tuesday was that their two best players from that series are returning to fitness, with Mitchell Starc and Steve Smith both sighted in the nets with a red ball after finger and quad injuries.
Cummins also bowled nicely on field, taking 2-37 and unlucky not to have one more wicket early when he hit Charith Asalanka’s leg stump with the left-hander on one.
However the bail did not fall off, allowing Asalanka to lead Sri Lanka from 3-34 to 258 with his maiden international century of 110 from 106 balls.
News, results and expert analysis from the weekend of sport sent every Monday. Sign up for our Sport newsletter.