Heidenheim grabbed third place despite losing 3-0 to Arminia Bielefeld and will face 16th-placed Bundesliga club Werder Bremen in a promotion/relegation playoff over two legs.
Hamburg, relegated two years ago for the first time in their history, finished fourth despite needing just a point from their game.
2. Bundesliga
Another Dynamo Dresden player tests positive for COVID-19
21/05/2020 AT 15:38
They were 2-0 down after 21 minutes through an own goal from Rick van Drongelen and Kevin Behrens's quick break.
An Aaron Hunt penalty in the second half gave Hamburg renewed hope.
Behrens, however, grabbed his second goal with a spot-kick in the 84th to kill off Hamburg's chances of top-flight football, before Mario Engels added a fourth in the 89th and former Hamburg player Dennis Diekmeier fired in number five with the last kick of the game.
Second division champions Bielefeld and VfB Stuttgart have won automatic promotion, securing first and second place respectively before Sunday's matches.
Paderborn and Fortuna Dusseldorf were relegated from the Bundesliga.
2. Bundesliga
Setback for German football as entire Dynamo Dresden squad forced into quarantine
09/05/2020 AT 19:18
Kylian Mbappe drops hint over Real Madrid transfer - Paper Round