The hosts got off to the worst possible start in Belfast when they fell behind with just two minutes on the clock.
Germany continued to push forward following the breakthrough and doubled their lead on 21 minutes, Sandro Wagner collecting the ball on the edge of the box, getting the better of Gareth McAuley and striking a vicious left-footed shot into the net.
The visitors were unlucky not to add a third by half time, although Michael O'Neill's charges tested the opposition defence late on when Corry Evans forced a save from Marc-Andre ter Stegen before Kyle Lafferty had a header smothered by the goalkeeper from the corner.
Northern Ireland stepped up their game after the restart and, despite being tested by Joachim Low's side, found themselves within a whisker of halving the deficit in the 77th minute when Conor Washington turned past Jerome Boateng and rattled an effort against the bar.
Eventually, the Germans were able to kill the game off for good when, four minutes from time, Joshua Kimmich drilled home from a tight angle after Jonny Evans headed a cross away off the line, only for the ball to fall to the Bayern Munich midfielder.
However, Northern Ireland's hard work saw them claim a consolation goal in injury time when a deep corner was flicked on by Gareth McAuley and glanced home by Josh Magennis.