Augsburg salvaged their Bundesliga status for a second straight season as a dramatic win over Bavarian rivals Greuther Furth lifted them out of the relegation zone for the first time all season on the final day.
Furth missed a penalty early on through Edgar Prib before Tobias Werner put Augsburg in front.
With Fortuna Dusseldorf behind at Hannover, that goal meant Augsburg were safe, and survival looked certain when Jan-Ingwer Callsen-Bracker headed in a second.
However, Furth refused to lie down and Florian Trinks brought them back into the game, setting up a nervous ending in the Augsburg Arena.
The home fans' nerves were settled by Ji Dong-won, though, as Markus Weinzierl's side completed an amazing recovery in the second half of the season to stay up.
The game could hardly have got off to a worse start for Augsburg when the referee pointed to the spot when Felix Klaus was brought down in the area by Ragnar Klavan in the third minute.
Edgar Prib stepped up and scored, but the referee ordered him to retake it for players encroaching.
Alexander Manninger then guessed right to deny Prib's second attempt.
Augsburg took the lead after half an hour as Werner's direct free-kick went in with Wolfgang Hesl slow to react.
The home team's efforts were then rewarded with a second goal when Callsen-Bracker headed the ball in the 55th minute.
Weinzierl's men then seemed to take their foot off the accelerator and they were punished, with Trinks pulling a goal back for Furth.
The visitors, whose relegation to the second division was sealed weeks ago, suddenly gained control of the game and Augsburg's lead was beginning to look precarious before Ji struck 15 minutes from time.
With Dusseldorf losing, the win earned Augsburg a place in the Bundesliga next season.