Marvin Plattenhardt's second-half free-kick preserved Hertha Berlin's Bundesliga status as they fought back to beat Hamburg 2-1 on aggregate.
Hamburg won the first leg 1-0 last week, but they will remain in 2. Bundesliga after Felix Magath's side consigned them to a 2-0 defeat at Volksparkstadion on Monday.
Captain Dedryck Boyata levelled the play-off when he rose to head Plattenhardt's corner into the back of the net only four minutes in.
Hertha were in front after 63 minutes, when Plattenhardt's set-piece from wide on the right flew over Hamburg goalkeeper Daniel Heuer Fernandes and into the far corner of the net.
Stevan Jovetic could have sealed it when he went one-on-one with Fernandes but was denied by the keeper.
That miss did not prove to be costly as Hertha held on to remain in the top flight despite Lucas Tousart's stoppage-time sending off for a second bookable offence on a painful night for Hamburg.
There was a brief celebration from Magath, who was appointed as Hertha head coach until the end of the season in March, after his side stayed up at the expense of a club where he had great success as a player and also served as a coach.
Hamburg have been in the second tier since they dropped out of the Bundesliga for the first time in their history four years ago.