Ian Baraclough’s side faced Slovakia, who were without the injured Martin Dúbravka, in the play-off final with a place at next summer’s finals at stake.
Lewis started for the hosts at Windsor Park in Belfast, but they got off to a poor start when Juraj Kucka took advantage of a lapse in concentration and broke away before slotting home the opener just over quarter of an hour into the contest.
It took until three minutes from time for Lewis’ side to level through Milan Skriniar’s own goal.
But in the second period of extra time, with ten minutes remaining until penalties, Michal Duris pounced to fire home what proved to be the winner.
Full back Lewis played the full 120 minutes for Northern Ireland as he missed out on the chance to play in what would have been his first major international tournament - but goalkeeper Dúbravka could feature in his first after Slovakia’s qualification.
There was penalty shoot-out joy for Scotland, though, as they reached their first tournament since the 1998 World Cup in France thanks to victory over Serbia.
Ryan Fraser missed out on the play-off final through injury but could feature at EURO 2020 next summer after his country’s win, which came after former Magpie Aleksandar Mitrovic missed the decisive penalty in the shoot-out for the hosts following a 1-1 draw after 120 minutes.
Another United man, Jeff Hendrick, had an evening to forget as his Republic of Ireland side were beaten 3-0 by England at Wembley.
Goals from Harry Maguire, Jadon Sancho and Dominic Calvert-Lewin settled the friendly in the Three Lions’ favour, with Hendrick completing 90 minutes in midfield.
And Miguel Almirón played an important role as Paraguay drew 1-1 with Argentina in a World Cup qualifier in the early hours of Friday morning.
The Magpies’ winger’s burst into the box was abruptly halted on 21 minutes, giving his side a penalty which Angel Romero dispatched.
Nicolas Gonzalez levelled before the break for the hosts in Buenos Aires, while Almirón – who turned in a good display against Lionel Messi and his team – was replaced in the closing minutes after picking up a yellow card.