Borussia Dortmund came from behind to get their season back on the rails after back-to-back defeats with a 2-1 win at Mainz.
Nicolai Muller put the hosts in front in the 33rd minute, but Ivan Perisic's first Bundesliga goal in the 64th minute brought Dortmund level.
Lukasz Piszczek then clinched the win for the Westphalians with practically the last kick of the game, taking them back into the top ten, six points adrift of league leaders Borussia Monchengladbach.
Mario Gotze was back in the Dortmund team after missing their last two games due to suspension. And he soon showed what the Dortmund team had been lacking in those two matches with a dangerous cross from the left wing in the tenth minute which Robert Lewandowski headed goalwards, forcing a fine instinctive save out of Heinz Muller.
Dortmund continued to hold the upper hand, but it was Mainz who took the lead against the run of play in the 33rd minute. And there was a bit of fortune attached to Muller's goal too, as he managed to beat Roman Weidenfeller at the second attempt while lying on the ground.
The goal did not break up Dortmund's rhythm too much, though, and Ilkay Gundogan and Lewandowski both missed excellent chances to level before the interval, the latter denied by Muller in a one-on-one situation.
Double gives Dortmund points
The equaliser finally arrived in the 64th minute with Lewandowski touching a right-wing cross back for Perisic, whose first touch saw him skip past one Mainz defender before he shot low into the bottom left-hand corner of Muller's goal.
It was now Mainz's turn to react and they had two great chances to win the game in the last ten minutes, first with Andreas Ivanschitz failing to spot team-mate Anthony Ujah in acres of space before seeing his shot saved by Weidenfeller.
But it was Dortmund who had the last word, with Piszczek netting the winner. Muller punched Gotze's free-kick away and Piszczek sent the ball back past him in an instant to earn Dortmund all three points in the last minute.