Hamburg scored a 90th-minute equaliser to force extra time before extending their 52-year Bundesliga stay with a 3-2 aggregate win over Karlsruher.
After Marcelo Diaz's curled free-kick cancelled out Reinhold Yabo's composed finish, Nicolai Muller turned in with the tie five minutes from penalties.
Karlsruher saw a 120th-minute penalty saved but Hamburg would have won on away goals had Rouwen Hennings scored.
Hamburg remain the only Bundesliga club never to have been relegated.
The north German club have been ever-present since the league was formed in 1963, and last season narrowly came through another relegation play-off against Greuther Fuerth, winning on away goals.
And after finishing 16th in the league table again this year, Bruno Labbadia's side had to play Karlsruher, who finished third in the second-tier 2. Bundesliga.
Thursday's first leg ended 1-1 and Karlsruher went ahead in the tie when Yabo slotted home through Rene Adler's legs.
The home side were moments away from promotion when Diaz curled home his first ever Hamburg goal in the last seconds of normal time.
Having forced extra time, six-time German champions Hamburg, who had former Tottenham midfielders Rafael van der Vaart and Lewis Holtby in their starting XI, all but ensured victory with a second goal that left Karlsruher needing to score twice.
Hennings' penalty, awarded for handball amid protests from the Hamburg players, was then saved by goalkeeper Adler, playing against his former club.
Hamburg players
Adler saved a last-gasp penalty but Hamburg would have still progressed if the game had finished 2-2
Hamburg players
Muller came on as a substitute to score Hamburg's winning goal in extra time
Karlsruher
Karlsruher finished third in Germany's second tier this season and were seconds away from promotion

LINEUP, BOOKINGS (0) & SUBSTITUTIONS (0)

Karlsruher SC

    Substitutes

    • Yabo

    Hamburger SV

      Substitutes

      • Díaz
      • Müller

      MATCH STATS

      Possession50%50%0minsKarlsruher SCHamburger SV

      Shots

      00

      On target

      00

      Corners

      00

      Fouls

      00