Northern Ireland threw away a two-goal lead in Luxembourg but a 2-2 draw was enough to earn promotion to League B in the Nations League.
Isaac Price and Conor Bradley gave Michael O'Neill's side a two-goal lead but the hosts hit back.
Quickfire goals by Seid Korac and Gerson Rodrigues stunned Northern Ireland and set up a tense final 15 minutes.
However, Northern Ireland held on to secure the point they needed to finish in top spot on Group C3.
The pre-match message from O'Neill and captain Shea Charles had been to press for the win and not to settle for a draw, and Northern Ireland made a bright start as drizzle fell at the Stade de Luxembourg.
They made the breakthrough when Shea Charles' low pass into the area was dummied by Dion Charles, and Price was on hard to steer an effort into the bottom corner.
With a one-goal advantage at half-time, Bradley's goal in the 51st minute gave Northern Ireland a buffer but they would soon relinquish it.
The Liverpool full-back rose highest to head Price's cross towards goal, and goalkeeper Tiago Pereira could only push the ball into his own net as Bradley wheeled away to celebrate with the ever-vocal Green and White Army.
However, Northern Ireland were stunned when Korac and Rodrigues netted in the space of three minutes but O'Neill's young side regrouped to hold on for the point they needed to finish top.
In a strong start, Dion Charles was almost played through after a superb pass by goalkeeper Pierce Charles, but the Bolton striker was denied as Korac put in a superb last-ditch tackle in the wet conditions.
Shea Charles, wearing the armband for the second time, and Dion Charles linked up well to find Ethan Galbraith down the right and his low, fizzed cross was just beyond Price in the middle of the area.
However, the Standard Liege midfielder made amends moments later when he curled a delightful, first-time effort into the bottom corner after Dion Charles stepped over Shea Charles' pass into the area.
It was a fourth goal of the campaign for Price, who also netted a hat-trick against Bulgaria in Belfast in October.
Midfielder Charles blazed an effort well over before Luxembourg's only chance of the half came when Rodrigues fired a free-kick into the wall, and the striker's powerful follow up flew wide of the goal.
Price was involved again as he cut inside from Bradley's pass, and his effort was gathered at the second attempt by Thiago Pereira with Dion Charles lurking.
Bradley was having a quiet game compared by his own high standards, but he almost set Price up for a second when he ran into the area and cut the ball back for the goalscorer, who mishit his effort well over the bar.
Isaac Price gave Northern Ireland the lead in Luxembourg
The first real chance of the second half ended up in the back of the net as Bradley headed Price's cross towards goal, which Pereira got a touch on but he could only push it into his own net.
Ruairi McConville, on his first start, headed over from a corner as Northern Ireland had the wind in their sails and their confidence in attack was on display again when when Bradley touched Price's cross narrowly wide from close range.
However, there was a twist to come when Korac slid the ball into the net off goalkeeper Charles, who conceded for the first time in a Northern Ireland shirt.
Northern Ireland were stunned three minutes later when Rodrigues fired into the top corner after bringing the ball down in the area to set up a tetchy final 15 minutes.
Ethan Galbraith let fly from the edge of the area as the visitors halted the momentum but substitute goalkeeper Ralph Schon pulled off a strong save.
Bradley fired a dangerous low cross across the face of goal but no one was in the area to capitalise, but Northern Ireland held on to earn the point required.
Their cause was helped by Belarus drawing 1-1 with Bulgaria, which meant even a defeat would have kept Northern Ireland top of the group.
The result not only earns promotion to League B, but it also keeps open the possibility of a play-off for the 2026 World Cup.
After the traditional World Cup qualifying campaign has come to a conclusion, the four highest-ranked Nations League group winners who did not finish in first or second place in their group will be awarded one of four additional play-off positions.
Of course, the most simple route for O'Neill's youthful side is to get the job done by finishing in the top two in their qualifying group, but it will be nice for Northern Ireland to have that back-up option should it be required.
The draw for World Cup qualifying takes place on Friday, 13 December.