Luca Waldschmidt’s 88th-minute header sealed Hamburg’s Bundesliga survival and condemned opponents Wolfsburg to a relegation play-off.

Wolfsburg, who won the title in 2008-09 and reached the Champions League quarter-finals just last season, must tackle the third-placed team from Germany’s second tier to determine their fate. With one round of that division remaining, that team is likely to be local rivals Eintracht Braunschweig.

Robin Knoche had put Wolfsburg ahead but Filip Kostic levelled for Hamburg, who were still facing the play-off until Waldschmidt’s late winner.

Elsewhere, champions Bayern Munich finished their campaign with victory over Freiburg. Arjen Robben, Arturo Vidal, Franck Ribéry and Joshua Kimmich scored in a 4-1 win which means Carlo Ancelotti’s side finished 15 points clear of Leipzig. It also marked the final game for captain Philipp Lahm and Xabi Alonso before retirement.

Philipp Lahm leaves the pitch for the final time...what a career!



👊 701 career games

🏆 22 trophies won



One of a kind 👏 pic.twitter.com/oGHvQwrZKG — BT Sport Football (@btsportfootball) May 20, 2017

Leipzig, who finished their debut top-flight season in second place, lost a 2-0 lead in the final seven minutes of their final game, as Eintracht Frankfurt’s Jesus Vallejo and Danny Blum scored to cancel out goals from Marcel Sabitzer and Yussuf Poulsen.

Pierre-Emerick Aubameyang’s late penalty handed Borussia Dortmund a 4-3 win over Werder Bremen to clinch third and a guaranteed place in the Champions League group stages next season. Aubameyang’s two goals also meant he finished as the Bundesliga’s top scorer with 31 goals, one ahead of Bayern’s Robert Lewandowski. Dortmund’s season ends next weekend when they meet Frankfurt in the German Cup final.

Hoffenheim drew 0-0 with Augsburg and will compete in the Champions League play-offs after finishing fourth, while Köln beat Mainz 2-0 thanks to goals from Jonas Hector and Yuya Osako to qualify for the Europa League – their first appearance in a major European tournament for 24 years.

Hertha Berlin dropped to sixth place after a 6-2 home defeat by Bayer Leverkusen. 17-year-old Kai Havertz scored twice as 12th-placed Leverkusen finished a disappointing campaign on a high