Bayern sign off season with 4-3 win at Gladbach
Fielding a full-strength team, Bayern, who set a string of league records, including most points (91) and fewest goals conceded (18) in 34 league games, went behind as Martin Stranzl and Mike Hanke scored twice within five minutes before Javi Martinez pulled one back on seven minutes.
Havard Nordtveit restored Gladbach's two-goal advantage in the 10th minute, as the hosts looked for a high score win in their last hope for a Europa League spot, before Frenchman Ribery's powerful effort made it 3-2 eight minutes later.
In what was the final Bundesliga match for coach Jupp Heynckes, who fittingly learned his trade at Gladbach as both player and coach, Ribery levelled with a sensational 18-metre volley from a deep Philipp Lahm cross in the 53rd minute.
Six minutes later he set up Dutchman Arjen Robben for the winner with a perfectly-weighted cross at the far post.
"I think our mind was still at the title celebrations at the start," said 1974 World Cup winner Heynckes, who is still the Bundesliga's third highest scorer and has made 1,011 league appearances as both player and coach. "But we stayed with it and gradually took control of the game.
"I had the feeling my players really wanted to win. I had told them before the game that this was my last Bundesliga game and it was here that I started in 1964," said Heynckes. "I saw they were really happy afterwards that they gave me such a present.
"It is a moving moment for me and I want to thank all Borussia fans. This shows that this is my home," he told reporters.
Heynckes's team, however, has still two finals to play with the German Cup final against VfB Stuttgart on June 1 and the chance for Bayern to claim an unprecedented treble of titles for a German club.
Second-placed Dortmund, also in their Champions League final dress rehearsal, suffered a late meltdown, conceding two goals as Hoffenheim staged a last-gasp relegation escape with a 2-1 win thanks to two Sejad Salihovic penalties, earning them a relegation play-off with second division side Kaiserslautern.
Dortmund had keeper Roman Weidenfeller sent off in the 80th minute with Salihovic converting his second penalty in five minutes to complete a stunning turnaround, having gone a goal down through Robert Lewandowski's sixth-minute opener.
Dortmund had the ball in the net deep in stoppage time but Marcel Schmelzer's effort was ruled offside in a dramatic end to Hoffenheim's rollercoaster season.
Schalke 04 beat Freiburg 2-1 to grab fourth place and a spot in the qualifying rounds of the Champions League, rescuing a season that had them seemingly out of contention at the halfway mark.
Bayer Leverkusen's Stefan Kiessling was the season's top scorer with his 25th strike in the last minute for a 1-0 win at Hamburg SV, helping his team to a comfortable third-place finish and secure Champions League action next season. Dortmund's Lewandowski ended up with 24 goals in second place.
Freiburg will join Eintracht Frankfurt in the Europa League next season.
Promoted Fortuna Dusseldorf completed a disastrous run since the winter break with no win in their last 12 games to tumble back down after slumping to a 3-0 defeat at Hannover 96 with Ivorian striker Didier Ya Konan scoring twice.
Augsburg finished a remarkable recovery since the winter break with a 3-1 win over already-relegated Furth to stay out of relegation trouble in 15th place.