Bremen entered the final day in the playoff spot, a point behind Frankfurt, and knowing victory would ensure their survival.
The visitors had looked to be safe until the 88th minute, when Chelsea loanee Papy Djilobodji diverted the ball home following a free kick amid suggestions of offside.
- SV Werder Bremen EN (@werderbremen_en) May 14, 2016
The goal was allowed to stand and gave Bremen a 1-0 win that saw them end the campaign in 13th.
Frankfurt will now play a two-legged playoff with the third-placed side in the second tier, Nurnberg, to decide which club will play in the top flight next season.
Stuttgart suffered their first relegation in 41 years after a 3-1 defeat at Wolfsburg.
Stuttgart, the 2007 Bundesliga champions, had needed a win at the Volkswagen Arena to have any hope of survival but had been in wretched form, taking just one point from their previous seven games.
Maximilian Arnold and Andre Schurrle struck in the opening 29 minutes for Wolfsburg, whose European qualification hopes were already over, to leave Jurgen Kramny's men with a mountain to climb in the second half.
Daniel Didavi, who is joining Wolfsburg this summer, fired in a free kick for Stuttgart in the 77th minute, but Schurrle added his second of the game in the dying moments to secure a 3-1 win.
Champions Bayern Munich beat already-relegated Hannover 3-1 in Pep Guardiola's final Bundesliga match in charge of the club.
Robert Lewandowski opened the scoring on 12 minutes -- becoming the first non-German to reach 30 goals in a season in the process -- and Mario Gotze clipped the ball over Ron-Robert Zieler for a second just before the half-hour mark.
Gotze, who is expected to leave the club this summer, added his second of the match on 54 minutes with a superb strike before Artur Sobiech pulled one back for Hannover 12 minutes later.
Borussia Dortmund shared a 2-2 draw with Cologne, a week ahead of arguably their most important game of the season.
Gonzalo Castro put Dortmund in front in the 11th minute, but Anthony Modeste and Milos Jojic turned the match on its head before the interval.
Marco Reus equalised for Dortmund, who will now look ahead to facing Bayern Munich in the final of the DFB-Pokal next weekend when they can get their hands on some silverware.
Borussia Monchengladbach secured their place in the playoff round of the Champions League next season with a 2-0 win at Darmstadt.
Thorgan Hazard gave Gladbach the lead on the half-hour mark, taking Granit Xhaka's pass past Lukasz Zaluska before scoring into an open goal.
Andre Hahn headed in their second after an hour to seal a comfortable win for the Foals.
Schalke secured their place in the group stage of the Europa League next season with a 4-1 win over Hoffenheim.
Klaas-Jan Huntelaar and Eric Maxim Choupo-Moting put Schalke two in front before Mark Uth reduced the arrears.
Leroy Sane added a third for Schalke before an own-goal from Fabian Schar completed the scoring.
Schalke head coach Andre Breitenreiter confirmed he will leave the club prior to the game.
- FC Schalke 04 (@s04_en) May 14, 2016
Mainz also secured their place in the Europa League group stage and ensured opponents Hertha Berlin will have to get through two qualifying rounds to join them with a 0-0 draw at the Coface Arena.
Bayer Leverkusen and Ingolstadt both gave the fans plenty of entertainment at the BayArena with the hosts emerging 3-2 winners, but everybody went home happy having seen their sides reach their objectives for the season.
Mathew Leckie gave Ingolstadt the lead in the 16th minute, but Charles Aranguiz and Kevin Kampl turned the game back in Leverkusen's favour before half-time.
Stefan Kiessling added a third on the hour mark before Ingolstadt's top scorer Moritz Hartmann added a second from the penalty spot.
Hamburg ended the season on a high with a 3-1 win at Augsburg, whose coach Markus Weinzierl has been linked with the vacant job at Schalke.
Information from the Press Association was used in this report.