BERLIN - Nils Petersen scored late for Freiburg to beat Bayern Munich 2-1 and escape the relegation zone while Stuttgart climbed off the bottom by beating Hamburger SV 2-1 in the Bundesliga's penultimate round Saturday.

Petersen scored in the 89th minute, three minutes after coming on as a substitute, for Freiburg to climb to 34 points, level with Hannover, which won 2-1 at Augsburg, and one point above Stuttgart in the relegation playoff spot.

Paderborn defender Uwe Huenemeier's 88th-minute own goal was enough for Schalke to secure Europa League football with a 1-0 win and leave his side bottom, one point behind Hamburg, which slipped a point behind Stuttgart with one round remaining.

"We still have a game at home. We want a win to make the relegation playoff place a possibility," said Paderborn coach Andre Breitenreiter, whose side hosts Stuttgart on the final day of the season.

Borussia Moenchengladbach qualified directly for the Champions League with a 2-0 win at Werder Bremen, thanks to two second half goals from Raffael.

"We didn't get any pennants or trophies but still we've achieved something tremendous," said 'Gladbach sports director Max Eberl, whose side is assured of at least third place.

Borussia Dortmund lost 2-1 at Wolfsburg in a rehearsal for the German Cup final, Bayer Leverkusen defeated Hoffenheim 2-0, Mainz beat Cologne 2-0 and Hertha Berlin is all but safe after drawing 0-0 with Eintracht Frankfurt.

"We still need a point. Now we're in the situation we didn't want," said Hertha coach Pal Dardai, whose side can still be theoretically caught on 35 points.

Hertha visits Hoffenheim, Hamburg hosts Schalke and Hannover faces Freiburg on the final day.

In Freiburg, Mitchell Weiser crossed for Bastian Schweinsteiger to put Bayern ahead in the 13th, but Admir Mehmedi equalized with a fine individual effort after Schweinsteiger lost the ball in the 33rd.

Schweinsteiger hit the crossbar with a free kick in the second half as Bayern had 17 efforts on goal compared to the home side's nine, only for Petersen to claim the late winner.

"Today we had a bit of luck after so many weeks of misfortune," Freiburg coach Christian Streich said.

Dortmund got off to a bad start when Daniel Caligiuri opened the scoring in the first minute, but the Wolfsburg midfielder gave away a penalty 10 minutes later and Pierre-Emerick Aubameyang duly equalized from the spot.

Belgian midfielder Kevin de Bruyne, who had crossed for Caligiuri, set a Bundesliga record with his 21st assist of the season. Another Wolfsburg midfielder, Zvjezdan Misimovic, set the previous record of 20 in 2008-09.

Naldo's 49th-minute goal proved enough for Wolfsburg to consolidate second place.

In Stuttgart, Gojko Kacar scored for the third successive game to give Hamburg a 12th-minutre lead. The Serb midfielder, who was told his contract would not be renewed after five injury-plagued seasons at Hamburg, rose highest to head Rafael van der Vaart's free kick past Stuttgart keeper Sven Ulreich.

However, Christian Gentner equalized with a shot through Rene Adler's legs in the 27th and Martin Harnik claimed Stuttgart's winner from close range eight minutes later.

Two goals from Hannover captain Lars Stindl gave his side its first win since beating Augsburg in the first half of the season.

Augsburg captain Paul Verhaegh equalized in the first half with a cheekily taken penalty only for Stindl, who will join Borussia Moenchengladbach in the summer, to score the winner in the 54th.

Hannover defender Hiroki Sakai was sent off with his second yellow card in the 77th, Verhaegh followed suit in the 90th and there was still time for Augsburg forward Raul Bobadilla to be sent off in injury time.

In Leverkusen, Hakan Calhanoglu scored from a free kick with the last kick of the first half and Stefan Kiessling made it 2-0 on a counterattack in the 61st.