BERLIN — Stuttgart secured its promotion to the Bundesliga after only one season away while Hamburger SV wasted any chance of a return from Germany’s second division in the final round on Sunday.

Stuttgart finished runner-up, 10 points behind already promoted Arminia Bielefeld, despite a 3-1 loss at home to Darmstadt. Former Germany striker Mario Gomez scored Stuttgart’s goal in his last game for the club.

“I am in negotiations with Real and Barça, and if nothing comes of that...” Gomez joked.

“It was my last mission for Stuttgart after we messed up last year (with relegation) to go back up again this year. My intention was to go then,” said Gomez, who will be 35 on July 10.

Hamburg started one point behind third-place Heidenheim. With a superior goal difference, a draw would have been enough for Hamburg to capitalize on Heidenheim’s 3-0 defeat at Bielefeld and finish in the promotion playoff spot. But former Bundesliga heavyweight Hamburg slumped to a 5-1 loss at home to SV Sandhausen, which only had pride to play for on the final day.

“There's no excuse,” Hamburg president Marcell Jansen said.

Former Hamburg midfielder Dennis Diekmeier scored Sandhausen’s fifth goal to rub salt in his former side’s wounds. It was only his second goal all season.

Hamburg was the last team to have played every season of the Bundesliga since the league was founded in 1963 until “der Dino” as it's affectionately known was finally relegated after a number of close calls in 2018.

Heidenheim next faces a two-leg playoff against Werder Bremen, which finished third from last in the Bundesliga, to see which side plays in the top flight next season.

“There was no happiness after the game, just disappointment with defeat today,” Heidenheim coach Frank Schmidt said. “Now we'll lick our wounds and get ready for Bremen.”

Nuremberg, which was relegated from the Bundesliga last season, dropped third from last in the second division after a 1-1 draw at Holstein Kiel, meaning Nuremberg must win a playoff against a third-division team to avoid a second straight relegation. Its opponent is not yet known.

___

More AP soccer: https://apnews.com/Soccer and https://twitter.com/AP_Sports

___

Ciarán Fahey on Twitter: https://twitter.com/cfaheyAP