Reinhold Yabo gave Karlsruher a 1-0 lead on the night and a 2-1 aggregate lead with his goal just over 10 minutes from time, but there was a sting in the tail of the tie.
Marcelo Diaz picked the best time to net his first goal for Hamburg, in the first minute of stoppage time, before Nicolai Mueller saved Hamburg's blushes with five minutes of extra time remaining, sealing a 3-2 aggregate win for the northern Germany side.
Hamburg arrived in Karlsruhe knowing they needed to score at least one goal to have any chance of staying up.
Hamburg relegated for the first time, Dortmund scrape into Champions League
12/05/2018 AT 15:29
While they had over two thirds of the possession and camped in the Karlsruher half, it rarely looked like that goal was going to come.
After an hour of soaking up the pressure, Karlsruher came out of their shells and gave visiting Rene Adler some work to do, and their own spell of pressure told as Yabo gave them the lead.
Rouwen Hennings chipped the ball over the Hamburg defence and Yabo latched onto it to volley in his first goal of 2015.
It did not change too much since a Hamburg goal was still needed to avoid relegation and just when it seemed like their fate was sealed, Diaz stepped up to deliver a 20-yard free-kick.
The home fans were holding their breaths as the Hamburg defender stepped up and opened his account with a curling effort over the wall and into the top left-hand corner.
It forced extra-time and gave Hamburg a lifeline, which they took with both hands.
Deflated by seeing their dreams dashed so late on, Karlsruher were now hoping to see things through to a penalty shoot-out, aware that may be their best chance of promotion.
That was snatched from them with just five minutes to go, though, as Mueller ghosted in unmarked to meet Cleber's cross from just a few yards out and convert the most important goal of Hamburg's season.
Hennings saw a penalty with the last kick of the game saved by Adler to sum up Karlsruher's night as HSV preserved their 52-year unblemished record as a Bundesliga side, having been the closest they have ever been to relegation.
Hannover top the Bundesliga after easy win over Hamburg
15/09/2017 AT 20:36
Aubameyang hits four in first game back after suspension
05/11/2016 AT 16:23