Two second-half goals saw Europa League qualifiers Mainz come from behind to beat bottom-of-the-table St Pauli 2-1 on the final day of the Bundesliga season this afternoon.
Despite securing European football for next year Mainz had lost seven games at home this campaign and it looked like they may lose an eighth after Mathias Lehmann had given Christian Heidel's side the lead just before half-time.
But the home side hit back in the second half thanks to an Andre Schurrle penalty and a late Sami Allagui goal.
Mainz started well and Austrian midfielder Andreas Ivanschitz came close after only eight minutes when he headed Malik Fathi's cross against the woodwork.
Ivanschitz had another fantastic opportunity to put fifth-placed Mainz ahead 10 minutes later after Schurrle's through-ball put him in on goal but he shot wide from 10 yards.
But despite their quick start to the game the hosts could not find a way through St Pauli's defence and they were made to pay in the 42nd minute when Marius Ebbers picked out Lehmann, who finished coolly from just inside the area.
Mainz scored their equaliser from the penalty spot on 58 minutes as Schurrle stepped up and sent the goalkeeper the wrong way after Allagui had been brought down by St Pauli defender Fabio Morena.
Tunisian international Allagui then scored in the 82nd minute when he turned Marcel Risse's cross home from six yards to give Mainz the win and send St Pauli down with only 29 points.