Australia 305 for 7 (Maxwell 108, Carey 106) beat England 302 for 7 (Bairstow 112, Billings 57, Woakes 53*) by three wickets
Their 212-run partnership rescued the tourists from 73 for 5 and resigned England to their first bilateral ODI series defeat at home since 2015.
Both fell in the dying stages, leaving it to Mitchell Starc to bring up the winning runs with a cool head and a swinging bat.
The result overturned Jonny Bairstow's powerful century, which had lifted England to a commanding total from their own troubled beginning.
Early wickets to Chris Woakes and an inspired turn by part-time spinner Joe Root had Australia in dire trouble in their pursuit of 303 before Maxwell's 108 off 90 balls and Carey's 106 sealed the series 2-1.
Going into the last international men's fixture of a belated English summer, the hosts teetered on 2 for 0 within the first two balls of the match.
But Bairstow's authoritative 112 from 126 balls, combined with half-centuries to Sam Billings - with whom he shared an innings-saving 114-run stand for the fifth wicket - and Woakes, allowed England to reach 302 for 7.
Woakes backed up his fine unbeaten 53 from 39 balls with two quick wickets to put Australia in trouble at 31 for 2.
Root's introduction looked on the surface to be a masterstroke by master captain Eoin Morgan, but had been foretold by the eventual dismissal of Bairstow earlier, beaten between bat and pad by a ball from seamer Pat Cummins which turned sharply into the batsman and clattered into the top of off stump.
Australia wobbled when Woakes had Aaron Finch and Marcus Stoinis out cheaply, the latter holding his place in the side after Steven Smith was left out again still feeling the effects of the blow to the head he took in training six days prior.
The tourists visibly slumped when Root dismissed David Warner with his fifth ball, which ripped off a middle-and-leg line to clip the top of off stump. Root then had Mitch Marsh out in his next over to a deflection onto his knee-roll which looped up and landed safely in the gloves of Jos Buttler.
Australia were 73 for 5 after Carey dabbed a Root delivery to the off-side and dashed off for a quick single, leaving Marnus Labuschagne exposed to Billings' sharp throw to Jos Buttler.
Australia should have been six down when Carey, on 9, holed out to Adil Rashid at third man, but it turned out that Jofra Archer had over-stepped and Carey was reprieved. Maxwell was also let off on 44 when he edged Rashid to Buttler, who failed to gather behind the stumps.
Carey and Maxwell brought up their 100-partnership off as many balls. By the end of the 35th over, Australia were 186 for 5 compared to England's 184 for 4 and Maxwell did his best to up the tempo when he thumped Rashid for a huge six into the second tier wide of long-on.
The sides were level after 39 overs - both 216 for 5 - and, as Morgan went to his seamers in the closing stages, the Australian duo dug in deeper. Maxwell brought up his second ODI hundred with a six off Tom Curran, taking him to 101 off just 84 balls, including four fours and seven sixes.
Carey moved to 99 heaving Woakes over the square-leg boundary and brought up his century with a single off the next ball.
Morgan brought on Rashid, who drew a top edge from Maxwell, caught by Curran at short third man, which left Australia needing 18 off the last 15.
Carey's knock ended when he sent an Archer delivery flying to third man, where Mark Wood took a sharp catch diving forwards on the last ball of the penultimate over.
With Australia needing 10 more runs and with new batsmen in Cummins and Starc, Morgan turned again to Rashid, whose first ball - a googly - was sent back down the ground for a six over long-off from Starc. Singles off the next two left Australia with two to get from three balls and, with Starc back on strike, he swept the next for four to seal victory with two balls to spare.
With England winning the toss and batting on a fresh strip, Jason Roy fell on the first delivery of the match, sending Starc straight to Maxwell at backward point. Starc compounded the blow on the next ball, trapping Root lbw with one that swung in and struck the pad in line with leg stump.
Morgan survived the hat-trick ball as he and Bairstow set about England's recovery effort. Bairstow was in fine fettle, his timing sublime as he picked off Australia's frontline seamers, seemingly at will, his pull shot particularly damaging. He clubbed Cummins over the fence at cow corner and added seven fours en route to 41 off 32 balls.
At the end of the Powerplay England were 67 for 2 and Australia introduced leg-spinner Adam Zampa to almost immediate effect when Morgan tried to loft him down the ground but failed to get under it and found Starc at mid-off. Zampa struck again when he had Buttler out for just 8 off 20, driving to Finch in the covers.
Billings joined Bairstow and the pair formed a formidable union. Starc conceded two sixes in as many overs to Billings, the second a deft hoick to fine leg where some of the England players and staff stood clapping with delight. They were applauding again when Billings sent Zampa to the boundary twice in the next over, bringing up his fifty in between with a pull to midwicket for two.
Bairstow brought up his 10th century in ODIs in emphatic fashion, whacking Cummins for six over square leg.
Billings was out top-edging a reverse sweep off Zampa to Mitch Marsh at short third man for 57 from 58 balls. But, when Bairstow fell to Cummins' gem, England weren't done.
Curran threatened with 19 off as many balls, including a six off Starc, but Starc replied next ball with a beautiful in-swinging yorker that crashed into off stump. Starc was on the other end of a glorious six by Rashid over square leg, but it was Woakes who pushed England past the 300-mark with some late swinging.
It wasn't enough as Australia saved their best for last at the end of a remarkable summer.