Michael Smith had given Northern Ireland a shock early lead on Tuesday, however Germany hit back in emphatic fashion with Leon Goretzka also grabbing a brace for the hosts before Julian Brandt's injury-time strike.
Gnabry's treble took his tally for 2019-20 to 14 goals for club and country as his fine start to the campaign continued with another clinical display.
Having finished third in the group, the Irish now find themselves in a play-off semi-final away to Bosnia and Herzegovina in March, where the winner will face either the Republic of Ireland or Slovakia.
Germany were stunned in the seventh minute when Toni Kroos could only head George Saville's cross to the edge of his own area and Smith unleashed a stunning low strike into the bottom-left corner beyond the reach of Marc-Andre ter Stegen.
Germany were almost level five minutes later after Ilkay Gundogan struck the post and soon they had their goal as Gnabry controlled Jonas Hector's cross from the left before swivelling and firing clinically into the far corner from 12 yards out.
Hector was again the provider two minutes before the interval as Germany turned the contest on its head.
His cross somehow evaded a crowd of bodies before the onrushing Goretzka made sufficient contact to send the ball agonisingly past Northern Ireland goalkeeper Bailey Peacock-Farrell and in off the post.
Within two minutes of the restart, Germany had a third as Lukas Klostermann found Gnabry, who again rifled home in clinical fashion.
Gnabry was celebrating his hat-trick just on the hour when he held off Tom Flanagan before drilling a low shot inside the far post.
Germany added further gloss, with Goretzka firing in from the edge of the area in the 72nd minute before Brandt struck from the left side of the box in added time.
What does it mean? Germany starting to look their old selves
For Germany, it is starting to look a case of 'Crisis? What crisis?'. Seven wins from a possible eight and top spot in a group including Netherlands, and things appear to be starting to click together again for Joachim Low and his team after last year's World Cup disappointment. There was no shame in this defeat for Northern Ireland. They have every reason to go into the play-offs in buoyant mood after giving the big boys a run for their money.
Gnabry continues deadly form
In his previous outing against British opponents – when club Bayern Munich faced Tottenham in the Champions League last month – Gnabry scored four times. On this occasion it was three. The former Arsenal man is a player reborn in the Bundesliga and looks one of Europe's hottest properties right now.
Smith's brilliant strike a silver lining for Irish
This was a night the Hearts defender will never forget after scoring the goal which put his team ahead against one of Europe's giants. What a goal it was as he demonstrated textbook technique to send a rasping low drive beyond Germany goalkeeper Ter Stegen.
A one-legged semi-final play-off away to Bosnia and Herzegovina awaits for Northern Ireland in March. Boss Michael O'Neill will be in charge for those matches despite his appointment at Championship outfit Stoke City, yet the search for his successor begins now for the Irish Football Association (IFA). With their place already booked, Germany can now look forward to next year's showpiece tournament.