The All Blacks, near perfect in their 30-0 win in Christchurch a week ago, lacked the same level of execution against a fired-up French side, who were let down in the final 10 minutes when lock Yoann Maestri was sin-binned for an apparent head butt.
Flyhalf Daniel Carter kicked 14 points and winger Ben Smith, a candidate for New Zealand's man of the series, added a contentious first-half try that looked like he had lost control of the ball as he slid in under two defenders.
France scrum-half Jean-Marc Doussain slotted two penalties and centre Florian Fritz added a dropgoal for the visitors who had openly stated they were using the three match series as a chance to develop new players for the 2015 World Cup.
Six Nations
Wales crowned Six Nations champions as Scotland beat France
26/03/2021 AT 22:08
That they pushed the world champions so close after making eight changes from their side that lost last week only proved that coach Philippe Saint-Andre's planning was at least on track.
The All Blacks were lucky to get away with the first test 23-13 at Eden Park and really only sealed the match last week in Christchurch in the final 25 minutes.
On Saturday in New Plymouth they were again hounded at the breakdown and found the visitors' set piece a lot more organised and resolute than the first two matches.
"Credit to the French they really stuck at it," All Blacks captain Kieran Read said in a televised interview. "A three match series is quite tough away from home and they showed the quality side they are.
"They really took it to us this game."
But for some wayward goal-kicking from Doussain in the first half, when the scrumhalf missed two eminently kickable penalties, the visitors could have gone into the break with a lead despite the All Blacks' playing a high-tempo style with quick ball and runners wide of the ruck to stretch the defence.
The visitors had taken an eighth-minute lead when Fritz landed a drop-goal, only for Carter to level the scores with a penalty eight minutes later.
Doussain and Carter combined to miss three penalties before Smith was put into space by fullback Israel Dagg, who drifted across field and cut out three defenders with a long pass that allowed the winger to slide over.
Doussain was finally successful with his third penalty attempt to ensure they went into the interval trailing 8-6.
The French scrumhalf gave his side the lead shortly after the break before the All Blacks finally got back on top of their opponents and Carter kicked three penalties.
Maestri ended any chance of his side fighting back when he was yellow carded by referee Nigel Owens in the 71st minute as he lunged at an All Black twice in a ruck, the second of which was spotted by Owens who said he had considered giving the Toulouse lock a red card before he reviewed television replays.
Replacement Barrett, playing on his home ground, then scored a last-minute try on the counter following some superb work by Smith to blow out the score.
"I was really impressed with the way the French turned up to play," Carter said. "They could have easily folded up and thought up about their off-season but they turned up to play and put us under a lot of pressure.
"But I was happy with that final 20 and to get away with the result."
Six Nations
France deny Wales Grand Slam in frantic finale
20/03/2021 AT 22:56
Six Nations
France's Dupont set to miss Scotland game after positive Covid-19 test
19/02/2021 AT 18:12