Heidenheim retained their spot in the Bundesliga for next season after a last-gasp 2-1 win at second-tier Elversberg in Monday's play-off second leg.
Léo Scienza struck the winner with a fine finish five minutes into stoppage time.
After a 2-2 draw in Thursday's first leg in Heidenheim, the return match was also full of drama at Elversberg's 9,000 capacity stadium as the Bundesliga third-bottom side edged second-division opposition for the 12th time in 13 seasons.
Only Union Berlin have won the play-off as a second-tier side in that period.
Heidenheim took an early lead through Mathias Honsak. But Robin Fellhauer levelled for the hosts on the half hour after the sort of flowing move which characterized their surprise surge up the second-tier table to third.
Elversberg thought they were ahead shortly after the break but a long video review ruled it out for a contentious offside.
The home side remained in the ascendancy, but with the away goals rule having been scrapped, the clash was headed for extra-time until
Scienza's special finish.