Gladbach had to withstand sustained pressure from its Bavarian rival until striking with a vengeance after the break as Oscar Wendt, Lars Stindl and Fabian Johnson were on target.
Bayern's late consolation at least gave it some cheer as substitute Franck Ribery scored on his first outing for nine months after injury.
It was Bayern's first defeat in the German top flight since losing to Freiburg in May and only its second reverse of this campaign, a 2-0 defeat at Arsenal in the Champions League, repaid in full in the return fixture,
Pep Guardiola's team has a lengthy injury list, but he was able to field an unchanged starting line up for the first time in 99 matches.
The 54,010 capacity crowd at Borussia Park saw the reigning champion have largely the better of play before the break with Kingsley Coman rattling a post.
But in the 54th minute Raffael set up Wendt for the Swedish international to fire past Manuel Neuer. Stindl volleyed home on 66 minutes to double the lead, with Johnson racing to clear beat the visiting goalkeeper five minutes later.
Arturo Vidal and Thomas Muller set up French star Ribery for his goal, but it was too little to late.
Guardiola was quick to praise the home side after a rare defeat, but said missed chances were the key to the setback.
"We played very well in the first half and created many chances. Unfortunately we didn't score any goals," he told gathered reporters. "After the first goal we lost our shape a little. Gladbach took advantage of that very well," he added.
Bayern's long-time rival Borussia Dortmund cut its lead to five points with a last-gasp 2-1 win Wolfsburg later Saturday while Borussia Moenchengladbach stays third.
Marco Reus looked to have given Dortmund its victory until Ricardo Rodriquez equalized with a 90th minute penalty but there was still time for substitute Shinji Kagawa to grab a winner.
In Spain's La Liga, Real Madrid returned to its best form with a 4-1 home thrashing of Getafe, with Karim Benzema setting his side on the way to victory with an early double in the Bernabeu.
An in-form Gareth Bale added a third in the 35th minute with Cristiano Ronaldo scoring the fourth before the break, his 17th goal this season..
More goals might have followed in what Bale called an "awesome atmosphere" but it was Alexis who grabbed a late consolation for the visitors.
It is also a welcome respite after a heavy defeat to Barca in El Clasico and being thrown out of the Copa Del Rey for an administrative error.
And there was further good news for Real later Saturday as Barcelona was held 1-1 at Valencia.
Former Manchester United and England international Gary Neville took over at the Mestalla this week and watched as his new charges fell behind to a Luis Suarez goal in the 59th minute.
With time running out, Santi Mina leveled for Valencia to steal a point for the home side.
In the three-way battle for the title, Atletico Madrid stayed second, just two points adrift of Barcelona with a 2-0 win at Granada, with Real a further two points behind.