Champions Bayern Munich needed some Franck Ribery magic to end the Bundesliga season with a dramatic 4-3 win at Borussia Moenchengladbach as they prepare to face Borussia Dortmund in the Champions League final next week.
Fielding a full-strength team, Bayern, who set a league record with 91 points and 18 goals conceded 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, before Ribery's powerful effort made it 3-2 eight minutes later.
In what is likely to be 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.
Second-placed Dortmund, also in their Champions League final dress-rehearsal, suffered a late meltdown, conceding two late goals as Hoffenheim staged a last-gasp relegation escape with a 2-1 win thanks to two Sejad Salihovic penalties, earning them a relegation playoff 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 later had the ball in the net 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.
Freiburg will join Eintracht Frankfurt in the Europa League next season.
Promoted Fortuna Dusseldorf completed a disastrous run since the winter break to tumble back down after slumping to a 3-0 defeat at Hanover 96.
Augsburg completed a remarkable recovery since the winter break with a 3-1 win over Fuerth to stay out of relegation trouble in 15th place.