Gian-Luca Waldschmidt's dramatic winner kept Hamburg in the Bundesliga courtesy of a 2-1 win over Wolfsburg at Volksparkstadion to condemn Andries Jonker's men to the relegation play-off.
A late Pierre-Michel Lasogga equaliser against Schalke last week kept Hamburg's hopes of snatching 16th place in the table off Wolfsburg alive, but it knew only a win on the final day would be enough to guarantee another year of top-flight football.
Wolfsburg looked well set as it drew first blood as Robin Knoche broke the deadlock in the 23th minute, beating goalkeeper Christian Mathenia with a strong header into the top left corner from Sebastian Jung's corner.
But the home side refused to throw in the towel and Filip Kostic levelled the scoring on the half-hour mark after being set up by Lewis Holtby.
Hamburg then went in search of the goal that would see it leapfrog Wolfsburg in the table, but initially struggled to find a way through as the away side held firm in defence.
Waldschmidt eventually came to the rescue, however, heading the ball past Koen Casteels in the 88th minute from Kostic's delivery to score his maiden Bundesliga goal just moments after coming off the bench.
Hamburg maintained its record of never being relegated, while 2009 Bundesliga champion Wolfsburg faces a nervy tie against one of Stuttgart, Hannover and Braunschweig to maintain it top-flight status.