The Foals established a three-goal lead within 21 minutes before a quickfire second-half brace from Breel Embolo put the game to bed on Wednesday night.
Borussia made a fairytale start in front of their home crowd as Kouadio Kone latched onto Embolo's assist from close range to beat Bayern goalkeeper Manuel Neuer with less than two minutes played.
The hosts should have doubled their advantage in the ninth minute, but Jonas Hofmann missed the target with only Neuer to beat. Two minutes later, Neuer was called into action once again as he had to tip Embolo's dangerous effort over the bar.
Bayern were visibly shocked and had to suffer another setback with 15 minutes gone as Ramy Bensebaini slotted home following a combination with Hofmann to make it 2-0.
To make things worse, Bayern conceded a penalty in the 21st minute when Lucas Hernandez fouled Embolo inside the box. Bensebaini stepped up and made no mistake to make it 3-0 from the spot, reports Xinhua.
Bayern's first clear-cut chance came 35 minutes into the game as Leon Goretzka's long-range attempt forced Yann Sommer into action for the first time.
After the restart, Bayern tried to take the upper hand, but things went from bad to worse in the 51st minute as Embolo had enough space to control a long ball between Bayern defenders Hernandez and Dayot Upamecano before nutmegging Neuer from the edge of the box.
Embolo remained in the thick of action and wasn't done with the scoring after Luca Netz's through-ball allowed the Swiss international to overcome Neuer for the second time in the 57th minute.
Bayern tried to respond but was never able to do any damage to Monchengladbach's well-positioned defense. The Foals stood firm for the remainder of the game to inflicte a heavy defeat.
"This is one of those nights you will never forget. We played very, very well and outplayed Bayern. And that is, something very special. I think we really impressed Bayern tonight. They really had no answer over 90 minutes," Monchengladbach's sporting director Max Eberl said.
With the result, Bayern Munich can now fully focus on the UEFA Champions League and the Bundesliga. Meanwhile, Borussia advance into the last 16.
Elsewhere, Bayern Leverkusen also crashed out of the German Cup after losing 2-1 to second division outfit Karlsruhe.
Bochum booked a place in the last 16 after beating league rivals Augsburg 5-4 on penalties.
Union Berlin needed extra-time to see off resilient third division side Waldhof Mannheim 3-1, and Anthony Modeste's second-half brace secured Cologne a 2-0 win over Stuttgart.