It was the away side who broke the deadlock in the 10th minute, with Alassane Pléa curling one beyond Manuel Neuer after combining with Hofmann.
It got better for the visitors int he 16th minute when Lars Stindl, who was making his first start, fired a low driven effort past into the net to double Gladbach's lead.
Bayern continued to dominate and carve out chances, but they were unable to find a way past Gladbach shot-stopper Yann Sommer, who pulled off a couple vital saves.
Gladbach, on the other hand, were happy to see out the closing stages of the first half and take a two-goal lead into the halftime break.
It was more of the same for the Bavarians in the second half, even with the introductions of Franck Ribery and Serge Gnabry.
Bayern had the ball in the back of the net after 68 minutes, but Robert Lewandowski's effort was chalked off by the offside flag.
While Bayern were dominating, Gladbach were still looking for another goal to seal the win in the closing stages.
And they were rewarded in the 88th minute thanks to a strike from Christoph Kramer as the visitors picked up a famous win.