Australia, chasing a target of 303, were all but out of the game at 73-5 when Maxwell came to the crease.
But an Australia record sixth-wicket stand of 212 between Carey (106) and Maxwell (108) gave the tourists a 2-1 success as England suffered their first home ODI series defeat in five years.
Maxwell’s hundred was just his second century in 113 matches at this level, with Carey’s innings the wicketkeeper’s maiden century in his 39th ODI.
But when Maxwell holed out off leg-spinner Adil Rashid, Australia still needed 18 off 15 balls. That became 10 off six when Carey, whose century came off 106 balls, was superbly caught by a diving Mark Wood at third man off Jofra Archer.
But new batsman Mitchell Starc - who’d got the match off to a stunning start by taking two wickets with the first two balls of the game - hit his first ball, from Rashid, for six and sealed victory with two balls to spare.
England were left to rue the fact that Carey was caught on nine off a Jofra Archer no-ball as they ended a coronavirus-hit season by suffering their first series defeat in 18 matches across all formats.
Australia’s success was all the more creditable as star batsman Steve Smith missed the entire series after suffering a head injury batting in the nets.
Jonny Bairstow had revived England from the depths of 0-2 with a superb hundred that saw them to 302-7.
Opening batsman Bairstow watched from the other end as left-arm quick Starc removed Jason Roy and Joe Root with the first two balls of the game.
But Bairstow counter-attacked superbly and his innings of 112 was the cornerstone of England’s eventual 302-7, with Sam Billings (57) and Chris Woakes (53 not out) making valuable fifties.
Pace bowler Woakes then took the first two wickets to fall, having Australia captain Aaron Finch lbw and Marcus Stoinis caught off a leading edge at midwicket to leave the tourists 31-2.
And Australia were 55-4 when Morgan saw his decision to bring on part-time off-spinner Joe Root rewarded by the Test captain taking two wickets for three runs in six balls.
Root, out for a golden duck, clean bowled David Warner (24) with a fine delivery that angled into the left-hander before turning sharply away as the opener completed a poor series that yielded just 36 runs.
Root then had all-rounder Mitchell Marsh spooning a simple catch to wicketkeeper Jos Buttler.
And when Marnus Labuschagne was run out, Australia were 73-5 in the 17th over.
But the big-hitting Maxwell, the last of Australia’s recognised batsmen, took advantage of a short boundary and brought up an 84-ball hundred with his seventh six, off medium-pacer Tom Curran.
England captain Eoin Morgan won the toss and batted on a fresh pitch.
But from the first ball, Roy edged a drive off Starc to backward point.
Next ball, Starc had Root lbw with an inswinger, the batsman not bothering with a review.
Left-hander Morgan survived the hat-trick before Billings gave Bairstow excellent support, completing a 53-ball fifty before he became one of three wickets for in-form leg-spinner Adam Zampa.
Bairstow went to his century in style with a legside six off a 90 mph delivery from Pat Cummins.
Bairstow’s tenth century in 83 matches at this level came from 116 balls, including 10 fours and two sixes, before he was bowled by Cummins’s slower ball.