The Ireland Under-20s were within a converted try of a famous win over perennial IRB Junior World champions New Zealand at the end of a titanic tussle in Vannes.
The Baby Blacks were certainly rattled as Ireland, 31-11 down at one stage in the second half, stormed back into it thanks to tries from Daniel Leavy and Edward Byrne plus five points from the boot of Rory Scannell.
A very entertaining and closely-fought first half ended 14-11 in New Zealand's favour, with Simon Hickey kicking three penalties and converting Patrick Tuipulotu's well-worked try.
Thomas Farrell's 35th minute touchdown, allied to a brace of Scannell penalties, kept Ireland well in the hunt although Farrell was sin-binned before half-time.
A run of three tries in a classy nine-minute spell put New Zealand coasting clear on the scoreboard, with hooker Epalahame Faiva touching down twice to supplement a Lolagi Visinia score.
However, Mike Ruddock's youngsters showed tremendous character to launch a spirited and skillful fight-back, captain Luke McGrath and Steve Crosbie impressing behind a tireless pack.
Replacements Peadar Timmins and Edward Byrne also caught the eye as Ireland pressed forward, creating tries for Leavy out wide and Byrne beside the posts.
Scannell added a conversion and a magnificent 70th minute penalty, following replacement prop Nick Grogan's sin-binning, to leave just five points between the sides.
Although New Zealand were shorthanded for the closing stages, they stood firm in a frantic finish – their skipper Ardie Savea proving very influential up front – to win Pool B and qualify for the semi-finals.
Ireland's first defeat of the tournament leaves them as pool runners-up and they will battle it out in the fifth-eighth place play-offs next week.
Their first play-off game is against tournament hosts France in La Roche-sur-Yon next Tuesday night (kick-off 8.15pm local time/7.15pm Irish time).
This was a truly heroic performance from Ruddock's side, particularly in the final quarter as they took the game to their bigger and pacier opponents.
To put the result in some context, New Zealand have been Junior World champions in four of the five years the tournament has taken place.
Between 2008 and 2012 they won 23 of their 25 JWC matches, beating Ireland twice in 2008 (65-10) and 2009 (17-0), so for Ruddock's current crop to run them so close is testament to the quality of their display.
Only England, in the 2009 final, have scored more points against New Zealand in this tournament (28 points), while today was only the third time in JWC history that the Kiwis have leaked three tries in a match – England touched down three times in both the 2009 and 2011 deciders.
But Ireland captain McGrath and his team-mates will not be consoled by those facts. They will feel this was a match they could have won in the end, and will look back in frustration at what might have been.
Ireland showed their physicality right from the kick-off, lock Gavin Thornbury at the centre of a tackle which produced the game's first turnover.
Christopher Taylor engaged early in the first scrum but the second set piece saw the Irish pack drive forward and they repeated the feat at the very next one, establishing a clear dominance of the scrum.
The Baby Blacks were exceptionally dangerous on the breakout though, Michael Collins leading an early charge and Penikolo Latu also tested the Irish defence out wide.
Ireland were unfortunate not to take advantage of a Josh van der Flier carry, and New Zealand broke from deep with speedy winger Visinia almost winning the race to a kick ahead.
The Irish clawed the territory back with Crosbie and Scannell breaking through tackles on the left and the latter slotted a fine penalty from the 10-metre line to open the scoring.
New Zealand's discipline was poor at times, they were guilty of going straight in off their feet at rucks but their attacking ability was hugely impressive.
The talismanic Savea charged forward and offloaded for the supporting Tayler Adams, who was tackled brilliantly into touch by Darragh Leader before he touched down in the left corner.
Hickey, who missed his first shot at the posts, was back on target on the quarter hour mark to punish flanker Leavy for a high tackle on the advancing Joseph Webber.
The Baby Blacks continued to build momentum in attack, an interception from Adam Byrne giving the Irish a much-needed breather from their defensive workload.
Hickey kicked the Kiwis ahead in the 20th minute after prop Peter Dooley was pinged for not rolling away quickly enough.
Ireland responded with a penalty-winning scrum and a half-break from Rory Scholes, and with play called back for the kick Scannell made no mistake from a left-sided position for 6-3.
The pace and precision of the New Zealand attack quickly got them back into scoring range, but Hickey pulled a difficult penalty to the right and wide.
Farrell, the penalty offender for hands in the ruck, had carried well early on and he was part of a rugged midfield resistance as New Zealand kept pressing for openings.
The breakthrough came in the 32nd minute as Visinia offloaded out of a tackle for big lock Tuipulotu to crash over in the left corner, with Ireland's determined defence finally giving way.
Hickey's conversion attempt came back off the left hand post and Ireland crucially managed to respond before the break.
Within three minutes they were back on level terms, Hickey throwing a loose pass just inside the Irish half and it broke for Farrell to gobble it up and race away to score in the right corner.
Scannell's conversion attempt fell narrowly wide and New Zealand managed to wrestle back control late in the half. An offside decision allowed Hickey land his third penalty and then Farrell saw yellow for repeated ruck infringements.
It was a frustrating call from an Irish point as New Zealand had coughed up a number of scrum penalties during the opening 40 minutes, but referee Ian Davies had issued a warning to the centre previously.
A ruck steal by van der Flier relieved some pressure on 14-man Ireland upon the resumption, before New Zealand could exploit the space in midfield.
Latu provided the spark on a ground-gaining run, number 8 Joseph Edwards set up a ruck in front of the posts and then a move out to the left led by centre Collins ended with Faiva stretching over.
The Baby Blacks' third try followed just two minutes later, quick hands releasing Visinia who got over despite a committed last-ditch challenge from Leader.
Hickey swung over the conversion and New Zealand tightened their grip on the game further when Faiva worked a short lineout and the return ball sent the hooker over for his second try in the corner.
The match officials were satisfied that he did not have a foot in touch before scoring and although Hickey failed to convert, the gap was now a sizeable 20 points.
Credit to Ireland, they showed great resilience to bounce back approaching the hour mark with the aforementioned Timmins and the Byrne twins, Bryan and Edward, really throwing their weight around.
Ireland scored their second try in the 58th minute, profiting from a muscular Farrell bust. Possession was retained following an Edward Byrne carry and a lovely pass from Crosbie allowed Scholes the space to put Leavy over in the far left corner.
After Scannell's missed conversion, Ireland continued to find holes in the New Zealand defence. Powerful prop Edward Byrne led the way again as he bulldozed up towards halfway and another strong charge saw him knock New Zealand scrum half Adams backwards.
The crowd were responding to Ireland's renewed efforts with ball in hand, making it feel slightly Dubarry Park-esque, and the Irish forwards gained further encouraging from their mauling.
They blew an opportunity from a five-metre lineout but regrouped to attack from further out, showing excellent ball retention and clearing out of the bulky Kiwi scavengers.
With 14 minutes left, Ireland swooped for try number three as Byrne, despite shipping a tackle, did superbly well to reach for the try-line and score from close range.
Scannell clipped over the conversion to the right of the posts and it was more of the same in the next spell as the Irish forwards eeked out the hard yards.
Grogan's yellow card for a maul infringement and Scannell's brilliantly struck penalty gave Ireland further encouragement, but time was not on their side and a couple of errors from an over-eager Scholes took the pressure off the New Zealand defence.
Referee Davies also reversed a ruck penalty near the Kiwis' 10-metre line after overzealous use of the boot by tighthead prop Taylor.
Ireland recovered possession for one final surge with McGrath's replacement David Shanahan firing passes left and right. New Zealand held back the tide just inside their 22, forcing an injury-time penalty at a ruck as Ireland's brave comeback bid fell agonisingly short.
Speaking afterwards, Irish captain Luke McGrath said: “I think, to be honest, a lot of our guys hadn't played against New Zealand before and we just threw the kitchen sink at them and you saw that.
“I think discipline cost us a little bit. It's a very tough one to take but I am so proud of the lads and how we played.”
Head coach Mike Ruddock admitted: “Every loss is tough to take when you are a coach, you want to win every game. That was a tough battle against quality opposition of course but I am proud of my team, I thought my players were fantastic.
“The patch after half-time, we were a man down and that was really the crucial time for us in terms of losing that control on the game. New Zealand ran in a couple of tries there.
“You have got to give our guys a huge credit, particularly to Luke as captain to rally his troops the way he did, get them back on track, we introduced some fresh blood and we worked hard, got back into the game and took it right down to the wire.
“We might not have won the game, but I think we won a lot of respect from a lot of people watching the game and a lot of teams watching the way we went toe to toe with a pretty formidable team.
“Probably that yellow card was a defining moment for us, you can't really give the All Blacks that sort of time and space and perhaps expect to win the game, even though we got very close.”
He added: “As disappointed as we are we can't dwell too much on it, we have got to learn from what happened last season to our team in South Africa.
“They lost one game and went on and won a few others and finished with a very respectable account of themselves in the tournament (finishing in fifth place) and that is what we have got to try and do.”
TIME LINE: 11 minutes – Ireland penalty: Rory Scannell – 0-3; 12 mins – New Zealand penalty: missed by Simon Hickey – 0-3; 16 mins – New Zealand penalty: Simon Hickey – 3-3; 20 mins – New Zealand penalty: Simon Hickey – 6-3; 24 mins – Ireland penalty: Rory Scannell – 6-6; 27 mins – New Zealand penalty: missed by Simon Hickey – 6-6; 32 mins – New Zealand try: Patrick Tuipulotu – 11-6; conversion: missed by Simon Hickey – 11-6; 35 mins – Ireland try: Thomas Farrell – 11-11; conversion: missed by Rory Scannell – 11-11; 40 mins – New Zealand penalty: Simon Hickey – 14-11; 40+2 mins – Ireland yellow card: Thomas Farrell; Half-time – New Zealand 14 Ireland 11; 45 mins – New Zealand try: Epalahame Faiva – 19-11; conversion: missed by Simon Hickey – 19-11; 47 mins – New Zealand try: Lolagi Visinia – 24-11; conversion: Simon Hickey – 26-11; 54 mins – New Zealand try: Epalahame Faiva – 31-11; conversion: missed by Simon Hickey – 31-11; 58 mins – Ireland try: Daniel Leavy – 31-16; conversion: missed by Rory Scannell – 31-16; 66 mins – Ireland try: Ed Byrne – 31-21; conversion: Rory Scannell – 31-23; 69 mins – New Zealand yellow card: Nick Grogan; 70 mins – Ireland penalty: Rory Scannell – 31-26; Full-time – New Zealand 31 Ireland 26
Referee: Ian Davies (Wales)