Warren Gatland's final game as Wales head coach ended in defeat as New Zealand emphatically won the World Cup bronze medal at Tokyo Stadium.
New Zealand tries: Moody, B Barrett, B Smith (2), Crotty, Mo'unga
New Zealand conversions: Mo'unga (5)
Wales tries: Amos, Adams
Wales conversions: Patchell, Biggar
Wales penalties: Patchell
Warren Gatland's final game as Wales head coach ended in defeat as New Zealand emphatically won the World Cup bronze medal at Tokyo Stadium.
The All Blacks' 40-17 triumph consigned Wales to a fourth place finish for the second time in three World Cup campaigns under Gatland.
It also extended New Zealand's winning run against Wales to 31 Tests, having not lost in the fixture since 1953.
Gatland's 12-year reign, highlighted by four Six Nations titles, three Grand Slams and two World Cup semi-final appearances, could not find a fairytale finish.
🗣 "Probably a game too far for us really. I have loved my time in Wales. The people have been amazing and incredibly welcoming."@WelshRugbyUnion coach Warren Gatland reflects on defeat in his final game in charge of Wales #RWC2019 #NZLvWAL #RWCTokyo pic.twitter.com/0beZHGrtjA
— Rugby World Cup (@rugbyworldcup) November 1, 2019
New Zealand had the game sewn up by half-time through wing Ben Smith's try double, plus touchdowns for prop Joe Moody and full-back Beauden Barrett, with fly-half Richie Mo'unga kicking four conversions.
Wales countered through Hallam Amos' clever try and five points from Rhys Patchell, but centre Ryan Crotty's try and another Mo'unga conversion early in the second-half finished them off before Mo'unga added a late touchdown.
Wing Josh Adams scored a second Wales try, though, giving him seven in the tournament and breaking Shane Williams' Wales record for one World Cup campaign that he set 12 years ago.
Dan Biggar converted, leaving an under-strength Wales to take considerable comfort from a battling display that augers well for their future under Gatland's successor Wayne Pivac.
Gatland made nine changes for his final game in charge, with injuries sidelining players like Leigh Halfpenny, George North and Aaron Wainwright, while wing Owen Lane made a World Cup debut and lock Adam Beard also started.
All Blacks boss Steve Hansen, who is also standing down after the tournament, included the likes of centre Sonny Bill Williams, wing Rieko Ioane and flanker Sam Cane.
The Wales players did not follow England's example in the semi-final last weekend of encroaching over the halfway line while New Zealand performed their pre-match Haka.
They faced it in regulation fashion standing on their own 10-metre line, but Wales were soon back-pedalling under pressure before Mo'unga hit the post with a straightforward penalty chance.
But the All Blacks struck after five minutes following a charge by lock Brodie Retallick that ended with Moody touching down and Mo'unga converting for a 7-0 lead.
Wales showed some promising glimpses, with wing Adams prominent in attack, but New Zealand cut them open again in the 12th minute when scrum-half Aaron Smith broke sharply and found try-scorer Barrett.
Mo'unga again converted, and Wales were already hugely up against it, trailing by 14 points.
Wales then sacrificed two kickable penalties, and their forwards went close to breaching New Zealand's defence before Amos applied a neat finish, claiming a try that Patchell converted.
Wales continued to attack with freedom, and Patchell kicked a 27th-minute penalty that made it 14-10.
Wales' response to two early setbacks had been outstanding, and another pinpoint Patchell touch-finder took them back inside New Zealand's 22.
Both sides looked to attack at every opportunity, and New Zealand struck next when Smith worked his way over for a try, again converted by Mo'unga.
Wales continued to have plenty of possession, yet New Zealand finished the half well on top.
Smith sprinted over for a second try in five minutes, and another Mo'unga conversion made it 28-10 at the interval.
New Zealand had gone up a gear, and their fifth try arrived just two minutes into the second period, with Crotty crashing over and Mo'unga converting.
It looked like being a long second-half for Wales, and Gatland began making changes, with half-backs Biggar and Gareth Davies both going on.
New Zealand had the game done and dusted, though, to at least gain something tangible from a World Cup campaign that saw England end their hopes of a world title hat-trick.
Wales head coach Warren Gatland praised his "tired" side after what was his final game in charge.
"It was a bit disappointing in the first half. For them to score a try on half-time was disappointing," Gatland told ITV.
"The boys gave as much as they could, for three or four it was a game too far as they were pretty tired. Some guys came off the bench with more energy and we played better in the second half.
"We could perhaps have scored a few more, the defence was a bit soft tonight. We had a five-day turnaround from South Africa last week and New Zealand tonight but I'm really proud of the guys.
"We can enjoy tonight and celebrate what we achieved, not only at this World Cup but by all the players in the past 12 years.
"I want to thank all the people in Wales and hopefully I will be back at some stage.
"I'm looking forward to going back to New Zealand with the Chiefs but I have loved my time in Wales."
It was also the final Test at the All Blacks helm for New Zealand coach Steve Hansen.
He said: "It was important we came back and honoured the jersey.
"It was a tough old game for both sides and I want to congratulate Wales too as they will be feeling it at the moment.
"All tournament we had great defence and we played good footy all the way through, one bad game and you get knocked out. But very proud of the boys today."
When asked how it felt to have been in charge of New Zealand through such a successful period in their history, Hansen had to pause due to loud cheers from the crowd before answering: "A privilege."