Sri Lankan spinner Wanindu Hasaranga took four wickets in Colombo on Wednesday but could stop Australia grabbing an unassailable 2-0 lead in the three-match Twenty20 series.
Hasaranga took 4-33 in his four overs of wily leg-spin after Sri Lankan batters had once again failed to fire.
Australia then scored 126-7 in 17.5 overs for a tricky three wicket victory.
Openers Aaron Finch, with a 13-ball 24, and David Warner, 10-ball 21, gave Australia momentum toward what looked like an easy target.
But Finch and all-rounder Mitchell Marsh fell within 20 runs of each other to Hasaranga's spin.
The Australian batters struggled against some tight lines by Hasaranga and Dushmantha Chameera, who took one wicket for 31 runs in his four overs.
The visitors kept losing wickets through the middle to keep hosts interested.
Matthew Wade, who made 26 off 26 balls, and Jhye Richardson, who scored nine off 20, took Australia across the finish line with an unbroken stand of 27.
"There was a bit going, and we know Sri Lanka are a difficult team to face at home," Wade said after his player-of-the-match performance.
"We just knew we needed to get through their two main spinners and tick off the runs. It certainly helped that guys got off to a flyer at the start, so the run rate wasn't really an issue," he added.
Earlier, Maxwell opened the bowling for Australia with his off-spin and took 2-18 in his three overs to lead a tight Australian bowling performance.
Maxwell was well supported by pacers Jhye Richardson, who finished with 3-26 in his four overs, and Kane Richardson, who took four wickets and only gave away 30 runs in his spell.
The visitors kept Dasun Shanaka-led team under pressure with probing lines, sharp fielding and timely wickets.
Sri Lankan openers Pathum Nissanka (3) and Danushka Gunathilaka (4) fell early to Jhye and Maxwell before a 66-run stand between Charith Asalanka and Kusal Mendis gave some stability to the faltering innings.
Asalanka fell for 33-ball 39, with two fours and two sixes, to Maxwell and Mendis went soon after that to Jhye after a 36-ball 36.
The hosts' innings never took off and the team could only reach 63-2 after the first 10 overs and lost too many wickets in the second half of their innings.
Bhanuka Rajapaksa (13), Shanaka (14) and Wanindu Hasaranga (12) once again showed the weakness in Sri Lanka's inexperienced middle-order.
Josh Hazlewood, who was the top performer for his team in the first match, bowled four wicketless but tight overs for 16 runs.
"We were right there, but unfortunately we were not able to capitalise with the bat," Sanaka said.
"Different days, different reasons [for the batting failures], today the top order fell early," he added.
Finch said his bowling unit "did a fantastic job to restrict" the hosts on the wicket "that probably deteriorated as the game went on".
"Mathew Wade also showed his experience taking us through. There was a little bit of panic from our end, but that can happen when the crowd gets involved," Finch added.