Werder Bremen narrowly edged hosts Heidenheim on the away goals rule in their Bundesliga promotion-relegation playoff on Monday to preserve their top-flight status.
Three goals in the last five minutes ensured a lively end to a 2-2 draw after the two teams had played out a goalless stalemate in last Thursday's first leg in Bremen.
Heidenheim defender Norman Theuerkauf turned the ball into his own net in the third minute to hand Werder the lead.
Ludwig Augustinsson added a 94th minute strike while Tim Kleindienst equalised twice for Heidenheim, who finished third in the second division and were hoping to get promoted to the top flight for the first time.
Werder have spent only one season outside the German top flight but were forced into the playoff after finishing third from bottom this season.
A quick Werder breakaway set up a chance inside the home penalty area and in a moment of panic the 33-year-old Theuerkauf, who started his career at Bremen, turned the ball into his own net.
Heidenheim, who created a lively atmosphere as staff members in the stadium banged drums, blew horns and wound up an old air-raid siren, came alive after the break.
Substitute Stefan Schimmer blasted over the top from close range before David Otto narrowly missed with a header.
But they had to wait until the 85th minute to finally break through as Tobias Mohr thumped long range effort against the visitors' crossbar and it rebounded off the on-rushing Kleindienst into the net.
Heidenheim still needed to score a second to win promotion but as they pushed forward, they were caught out by a mazy run from Fin Bartels who set up Augustinsson to put Werder back ahead four minutes into stoppage time.
Celebrations were put on hold when Werder defender Theodor Gebre Selassie fouled Mohr and Kleindienst converted with the last kick of the game to make it 2-2 but Bremen were then able to begin the festivities.