Steven Davis and Gavin Whyte netted inside the final ten minutes as Northern Ireland got the better of Luxembourg.
David and Whyte scored in the space of two minutes late on as Northern Ireland snatched the victory. Luxembourg had looked the most likely winners after Marvin Martins equalised in the 58th minute.
This was Ian Barraclough’s first match in charge since he signed a two-year contract extension last year.
But despite a promising start and three goals, the manager will not have enjoyed everything he saw from his side at the Stade de Luxembourg.
Though they deservedly took the lead after dominating the opening exchanges, Luxembourg gradually took control of the game and looked the more likely winners after drawing level.
Luke Southwood, on as a half-time substitute to make his Northern Ireland debut, had to make a series of saves before Davis and Whyte delivered the win.
Davis had started the night on the bench, with Jonny Evans, back in the side after his sooner-than-expected recovery from a hamstring injury, taking the captain’s armband instead.
Shayne Lavery – making his first international appearance since September following injury – was quick to cause havoc as he twice came close to setting up Magennis in the first two minutes, then fired narrowly wide himself.
Corry Evans and Jordan Thompson both forced saves from Anthony Moris before the breakthrough came when Magennis muscled Maxime Chanot off the ball near the corner flag and raced at goal to finish from a tight angle.
But having taken the lead, Northern Ireland let their control of the game slip.
Missing the steadying influence of Davis in midfield, they allowed Luxembourg more of the ball and more chances, even if they could not get any of them on target in the first half as Daniel Sinani, on loan at Huddersfield from Norwich, and Gerson Rodrigues both spurned a series of chances
Jonny Evans, who had played 25 minutes for Leicester at the weekend in his first appearance since December, said on Thursday he would start the match and assess his condition at half-time, but the 34-year-old emerged after the break.
There was one change at half-time though as Southwood replaced Conor Hazard and quickly got his first touch as a mis-timed pass across goal from Tom Flanagan almost fell perfectly for Sinani.
Southwood was needed again in the 53rd minute when Rodrigues laid the ball off for Mica Pinto, but there was no venom in his shot.
Northern Ireland had not got going and the equaliser came in the 58th minute. Craig Cathcart had done well to beat Leandro Barreiro to a dangerous cross, but from the resulting corner Martins was on hand to head in at the back post.
Sinani and Rodrigues then both tested Southwood with Luxembourg well on top, prompting a quadruple substitution from Baraclough as Evans, Magennis, Lavery and Thompson made way for Davis, Ciaron Brown, Dion Charles and Gavin Whyte.
The changes helped Northern Ireland stem the Luxembourg tide, but the hosts still looked the more likely winners until it all changed in a frantic finish.
First Davis poked home his 13th international goal – only David Healy and Kyle Lafferty have more for Northern Ireland – after Charles saw his shot blocked, then Whyte latched on to a long clearance from Southwood and ran at Moris, sliding a low shot under the Luxembourg goalkeeper to find the bottom corner.