RB Leipzig led Bayern Munich 4-3 after 90 minutes, but David Alaba and Arjen Robben snatched all three points for the champions.
Sensational stoppage-time strikes from David Alaba and Arjen Robben saw Bayern Munich come from behind to beat RB Leipzig 5-4 in a pulsating match at the Red Bull Arena.
Leipzig looked to have the match sewn up as they led 4-2 in the 84th minute, but Robert Lewandowski pulled one back to set up a grandstand finish before Alaba and Robben produced moments of real quality to seal a remarkable turnaround.
Alaba's 91st-minute free-kick was added to by a sublime individual effort from Robben in the last minute of injury time, completing an astounding comeback and a display worthy of champions.
Despite their late collapse, Leipzig clinched second position as Borussia Dortmund were held to a 1-1 draw at Augsburg and can set a Bundesliga record points tally for a promoted club with victory at Eintracht Frankfurt next weekend.
Marcel Sabitzer opened the scoring after just 65 seconds but Lewandowski levelled from the penalty spot with his 150th goal in Germany's top flight.
A spot-kick from Timo Werner and a deflected Yussuf Poulsen effort put Leipzig two goals clear shortly after half-time, but Thiago Alcantara's header reduced the deficit.
Werner capitalised on shoddy defending from Philipp Lahm and Jerome Boateng to seemingly put the result beyond doubt, but Lewandowski headed home his 30th Bundesliga goal of the season with six minutes of normal time remaining.
Alaba and Robben then stunned the home crowd to spark scenes of jubilation among the Bayern players, who were whistled as they rightly celebrated long past the game's conclusion.
The match was explosive from the start and Leipzig took just over a minute to open the scoring, Emil Forsberg surging down the left and picking out Sabitzer to powerfully head beyond Tom Starke.
Werner rattled the base of the post but Ralph Hasenhuttl's side by no means had it all their own way and a handball decision when Lahm's cross struck Bernardo resulted in a penalty that Lewandowski sent beyond Peter Gulacsi.
The match continued in an end-to-end fashion with Starke denying Sabitzer and Bernardo before Alonso's trip on the quick-footed Forsberg conceded a spot-kick that Werner drilled into the bottom-left corner.
Franck Ribery took a blow to the ribs and had to be replaced by Douglas Costa before half-time and Bayern found themselves further behind within two minutes of the restart, Forsberg teeing up Poulsen whose scuffed shot was deflected past Starke by a touch off Alonso.
Lewandowski spurned a great chance to reduce the deficit but Thiago did not fail in the 60th minute, heading home unmarked at the back post after Alonso nodded Lahm's delivery across goal.
Werner punished Lahm's loss of possession and Boateng's weak challenge by slotting between the legs of Starke from a tight angle, but Leipzig would again surrender their advantage - this time in decisive fashion.
Lewandowski turned a square pass from Lahm onto the outside of the post before getting his second by heading into a vacant net after Robben's deflected strike crashed down off the bar.
Naby Keita's foul on Lewandowski was capitalised upon by Alaba with a sweet free-kick from 25 yards to level, and there was more drama at the death.
Released by substitute Thomas Muller, Robben raced away down the right before beating Stefan Ilsanker and Marvin Compper to get into the box and finish past Gulacsi in the 95th minute to cap a breathless finale.
Key Opta stats:
- This was the Bundesliga's highest scoring game this season.
- Robert Lewandowski scored at least two goals in a Bundesliga match for the 41st time and equalled his own record for a Bundesliga season with 30 goals (as in 2015-16).
- Thomas Muller assisted the winner. It was his 12th assist this season – a new personal record.