Bayern Munich fell to only their second defeat of the season, and their first at home, as fifth-placed Mainz blew the Bundesliga title race wide open with a 2-1 win in Bavaria.
Jairo Samperio gave Martin Schmidt's men the lead, but it looked like normal business had been resumed when Arjen Robben levelled.
When everybody was expecting a second Bayern goal, Jhon Cordoba stepped up to snatch victory for Mainz and leave Bayern empty-handed for the first time all season at the Allianz Arena.
With Borussia Dortmund beating Darmstadt, their advantage at the top is now just five points with Bayern travelling to Dortmund on Saturday.
Mainz showed no fear of their hosts, taking the game to them like few before them at the Allianz Arena, where Bayern had won all of their Bundesliga games this season.
The first shot on goal nevertheless came at the other end of the field with Loris Karius getting down low to turn an Arturo Vidal volley wide.
Karius then denied Juan Bernat as Bayern slowly started to get into their rhythm, but it was Mainz who drew first blood with Samperio meeting Giulio Donati's cross and beating Manuel Neuer from 10 yards.
Only 26 minutes were on the clock, yet it seemed already like Mainz had decided to defend their lead for the remaining 64 minutes.
Schmidt's men still produced the odd chance on the break, with a Donati cross asking for a Mainz player to turn it in just before half-time, but nobody was up in support of the Italian.
Christian Clemens wasted another excellent opportunity for the guests early in the second half when set up by Yunus Malli, but he lacked composure and sent his shot wide.
Pep Guardiola responded immediately and sent Thomas Muller on for Kingsley Coman, with Douglas Costa replacing Thiago Alcantara shortly afterwards and giving the Bayern coach five attack-minded players for the final 30 minutes.
The equalising goal came only four minutes later with Vidal squaring for Robben, whose 20-yard effort beat Karius low into the bottom corner.
With such an array of attacking talent on the field, it seemed just a matter of time before Bayern would strike again, while Mainz were no longer even looking for scraps on the break.
The third goal of the game eventually came in the 86th minute, but it was not what everybody was expecting.
Julian Baumgartlinger played the ball square to Cordoba who, with only Mainz's second shot of the second half, beat Neuer from 15 yards and sent the Allianz Arena into an eerie state of silence.
Robert Lewandowski had a chance to snatch a point for Guardiola's men deep in stoppage time, but the former Dortmund forward missed and Mainz celebrated a famous victory which will have earned plenty of cheers at Lewandowski's former club.