Wolfsburg came from behind to beat Hoffenheim 3-1 and secure their place in the Bundesliga next season on a dramatic day at the Rhein-Neckar Arena.
Roberto Firmino put the home side in front in the 49th minute and, with results elsewhere going against the Wolves, they were on the verge of relegation. A 60th-minute goal from Mario Mandzukic brought them level, but they still needed at least one more goal to be sure of their top-flight status.
Mandzukic obliged in the 73rd minute and Grafite sealed the win five minutes later as Felix Magath's side did enough to end the season two points clear of third-bottom Borussia Monchengladbach.
Wolfsburg knew that their destiny was in their own hands and that a win would be enough to remain in the Bundesliga, and they started strongly. Grafite missed their best chance in the 29th minute when he shot straight at Hoffenheim goalkeeper Tom Starke's legs after being put clean through on goal.
The Wolfsburg fans looked despondent as news filtered through that Monchengladbach had taken the lead against Hamburg just before half-time. As things stood at the interval, the Wolves were facing the prospect of a relegation play-off.
Matters soon turned from bad to worse as Hoffenheim took the lead through Roberto Firmino in the 49th minute. He skipped between two Wolfsburg defenders and beat Diego Benaglio to the ball to nudge it past the Wolfsburg goalkeeper and into the back of the net.
News then arrived that Eintracht Frankfurt had taken the lead against Borussia Dortmund, meaning that - with 40 minutes of the season remaining - the 2009 Bundesliga champions could end up heading straight down into the second division.
They needed two goals or a favour from Dortmund or Hamburg, and they got the first goal on the hour mark through Mandzukic. He was put through by Cicero and lifted the ball past Starke as he entered the penalty area to bring the visitors level.
The Wolves threw everybody forward in search of the goal which would have lifted them two positions and to safety. Sascha Riether missed a glorious chance to score it in the 69th minute, diverting his shot from Mandzukic's cross wide of the post just in front of Starke.
However, it arrived in the 73rd minute when Mandzukic met Ashkan Dejagah's corner at the near post and headed past Starke, who could only help the ball into the roof of the net, to send the visiting fans into a frenzy.
A curious goal from Grafite, who knew little about it as Riether's shot deflected in off his chest, then made absolutely sure of Wolfsburg's place in the Bundesliga next season in the 78th minute.