Frank Schmidt's side went into the final day with matters in their own hands and knowing that victory would complete their incredible rise up the divisions to the top flight of German football, something they had never achieved before.
However, just 24 hours after a Bundesliga final day filled with drama until the last second, Heidenheim looked to be on course to suffer the same fate as Borussia Dortmund in throwing things away at the final hurdle.
Jahn Regensburg took a shock 2-0 lead through Prince Owusu's brace shortly before the hour mark, while promotion rivals Hamburger SV had taken an early lead in their match against Sandhausen knowing that victory coupled with any dropped points for Heidenheim would see them go up.
Heidenheim therefore needed three goals without reply to be promoted, but they still trailed heading into injury time after an own goal had halved the deficit just one minute after they had fallen two behind.
However, Schmidt's men remarkably scored twice in stoppage time, including a 99th-minute winner, to earn promotion to the Bundesliga in the most dramatic fashion, leaping from third place to be crowned champions as Hamburg missed out.
Hamburg at least held up their end of the bargain, taking the lead at Sandhausen through Jean-Luc Dompe's third-minute strike and not surrendering that for the rest of the game.
Indeed, when they finished their match they were firmly in the promotion positions, with Heidenheim needing two goals in second-half stoppage time to overhaul them.
Nerves began to fray when Jan-Niklas Beste converted from the penalty spot in the 93rd minute to level things up on the day, and then the miraculous comeback was completed six minutes after that.
Tim Kleindienst was the hero for Heidenheim with his 99th-minute goal, which not only won the match but also won the title and earned promotion in the process, the title coming courtesy of Darmstadt's heavy defeat to Greuther Furth.
Heidenheim's promotion means that they will become only the second team, after RB Leipzig, to play in both the fifth tier and the Bundesliga this century.