Media playback is not supported on this device
The Irish led 22-17 but Ryan Crotty's try, converted at the second attempt by Aaron Cruden, saw the world champions end 2013 with a perfect 14 victories.
Tries from Conor Murray, Rory Best and Rob Kearney helped Ireland lead 19-0 before Julian Savea's reply.
"I think it was important for world rugby because this is a very good New Zealand team but it's not the best New Zealand team of all time, and they're certainly beatable. Yes, they've won every game this year, but I just feel Ireland showed the world you can beat this team. Even with Ireland losing today, it's great for world rugby and for the World Cup in a couple of years' time."
Ben Franks's score cut further into Ireland's lead before the late drama.
It was an agonising conclusion for the Irish, who were aiming for their first win over the All Blacks in 109 years of trying, New Zealand having won 26 of their 27 previous encounters, with one 1973 draw at Lansdowne Road.
While the final outcome brought total heartbreak for the hosts, the world champions underlined that status as they became the first side in the professional era to win every Test in a calendar year.
Ireland went into the game as rank outsiders after a dismal display in last weekend's 32-15 by Australia.
But Joe Schmidt's side were a totally different outfit from a week ago as they tore into the All Blacks in the opening stages with all the home players looking sharp.
A grubber kick from Brian O'Driscoll, equalling Ronan O'Gara's Ireland caps record of 128, forced a New Zealand knock-on as the home side earned a scrum just outside the opposition 22.
With the opening Irish scrum rock solid, Dave Kearney's dart infield immediately gave the Irish attack momentum and as the ball was kept alive, Murray was able to dive over from close range for a fourth-minute score.
There was more than a suspicion that Murray had spilled the ball in attempting to ground it but the verdict from the television match official ruled it a legitimate try, with Sexton quickly adding the extras.
(provided by Opta)
Incredibly, by the 10th minute it was 14-0 with O'Brien's burst deep into the New Zealand 22 the key component as he brilliantly off-loaded to Murray before the ball was recycled back to Best to dive over.
It was to prove the hooker's final contribution as he was forced off by a broken arm with Sean Cronin coming on.
But the Irish refused to be rattled by that blow as Rob Kearney ran from the edge of his own 22 to score a remarkable intercept try in the 18th minute after Israel Dagg had failed to hold a pop pass from Cruden.
Sexton missed the conversion but Ireland were 19-0 ahead in front of an amazed Aviva Stadium audience.
A New Zealand response had to come and it arrived in the 26th minute as a clever kick in behind from Cruden allowed Savea to gather and score with the fly-half adding the extras.
But undaunted, the Irish regrouped to produce more pressure with a Cian Healy smash past All Blacks skipper Richie McCaw bringing audible gasps from the crowd.
Further charges from O'Driscoll, Sexton and Devin Toner brought the Irish to within five metres of the line before New Zealand loose-head prop Wyatt Crockett was pinged for taking his man down.
Sexton duly added the penalty to extend Ireland's lead to 22-7 in the 33rd minute, a lead they maintained until the interval.
Ireland weathered the opening 10 minutes after the restart with Dagg being held up a hair short of the Irish line by a combination of Rob Kearney and Murray.
But a Cruden penalty did cut Ireland's lead to 12 points in the 52nd minute after Devin Toner had needlessly blocked Crockett as Sexton was about to clear to safety.
Cruden missed another long-range chance to cut into Ireland's lead before the home team suffered a blow as the inspirational O'Driscoll, much to his annoyance, was forced off because of the concussion guidelines.
"I don't know if the guys can get over this - it's hard to articulate the level of disappointment they will feel. They had the chance to beat the All Blacks and they didn't take it. All credit must go to the All Blacks - a lesser team would have wilted under pressure. Ireland's Jonny Sexton missed a penalty kick that he will never get over."
As the match entered the final quarter, New Zealand were beginning to dominate possession and it was little surprise when replacement Ben Franks dived over for their second try with Cruden adding the extras.
Suddenly, there was only five points in it but Sexton had a chance to put more than a score between the teams, only to nudge his penalty attempt wide from the edge of the All Blacks 22.
The Irish appeared set to run down the clock in the closing seconds of normal time, but replacement prop Jack McGrath was penalised for going off his feet at a ruck with 30 seconds of normal time to give the All Blacks a last-gasp lifeline.
And how they grasped it. A relentless assault into the Irish 22 was finished off by Dane Coles putting through his fellow replacement Crotty to dive over in the left corner with 81 minutes and 24 seconds on the clock.
The try levelled the contest with Cruden's difficult conversion to follow.
His initial attempt went wide but the Irish players had charged off their line too early, giving the fly-half a second chance which he slotted straight between the posts.
For a gallery of images from this match go to the BBC Sport Facebook page.
Ireland: R Kearney; Bowe, O'Driscoll, D'Arcy, D Kearney; Sexton, Murray; Healy, Best, Ross, Toner, O'Connell, O'Mahony, O'Brien, Heaslip.
Replacements: Cronin for Best (14), Fitzgerald for O'Driscoll (53), McLaughlin for O'Mahony (56), Fitzpatrick for Ross (65), McCarthy for Toner (65), McGrath for Healy (69), Madigan for Sexton (76).
Not Used: Boss.
New Zealand: Dagg; Jane, B Smith, Nonu, Savea; Cruden, A Smith; Crockett, Hore, Faumuina, Romano, L Whitelock, Luatua, McCaw, Read.
Replacements: Coles for Hore (42), Crotty for Dagg (52), O Franks for Faumuina (56), Messam for Luatua (56), B Franks for Crockett (60), Barrett(66).
Not Used: Cane, Perenara.
Att: 51,000
Ref: Nigel Owens (Wales).
Ireland remain without a win over New Zealand as a converted injury-time try for the All Blacks condemned the hosts to a heartbreaking defeat in Dublin.