The Frenchman came off the bench to salvage victory for the Bavarians, but Dortmund can still take the Bundesliga with a draw against Gladbach later on Saturday
Naldo opened the scoring early in the second half with a tap-in, before turning the ball into his own net with 15 minutes to go. Bayern laid siege to the Bremen goal in the closing stages, and eventually snatched the points at the death through the brilliance of Ribery, who came off the bench to score a great effort which moves the Bavarians to within five points of leaders Dortmund.
BVB can still clinch the championship later in the day, however, as a draw in their home match against Gladbach will be enough to make their second straight Bundesliga title a mathematical certainty with two games remaining.
Bayern coach Jupp Heynckes rested eight players from the 2-1 win against Madrid midweek, no doubt with one eye on the return fixture at the Santiago Bernabeu on Wednesday and the other on the near-insurmountable eight-point deficit to Dortmund at the start of play.
In came the likes of Nils Petersen and Diego Contento, as Arjen Robben, Ribery and Mario Gomez started the contest from the bench, while captain Philipp Lahm was left out of the matchday squad entirely.
Nevertheless, the Bayern second string nearly raced off to the perfect start, but Petersen showed his clear lack of match practice by failing to turn in Takashi Usami’s cross from point blank range.
Petersen had another bite at the apple in the 20th minute, this time from a cross by Contento, but Tim Wiese was alert to beat away his header.
The visitors looked the more comfortable side, but were nearly caught out by Markus Rosenberg, who somehow fired over the bar after being found unmarked in the area with Manuel Neuer out of position.
The match proceeded at a leisurely pace, with both teams in no hurry to force the issue in front of goal. Contento flashed a long range piledriver over the bar as the half seemed to be petering out to a stalemate.
However, a minute before the break, Bayern nearly found themselves ahead. Ivica Olic did well to beat his marker out wide and cut back to Petersen, who rattled the woodwork with a ferocious effort from just inside the area.
The Bavarians had another golden chance to take the lead three minutes into the second half after Thomas Muller put Olic clean through, but the Croatian fired wide with only the keeper to beat.
Bremen would make them pay for their profligacy as they immediately stormed down the pitch, Claudio Pizarro forcing a splendid save from Neuer with a powerful header from a Rosenberg cross. From the resulting corner, Pizarro came up trumps in the air again, flicking into Naldo’s path who blasted home from a few yards out.
Heynckes saw his team’s slim hope of the title slipping away, and decided to throw all his cards on the table, summoning Toni Kroos, Ribery and Gomez from the bench for the latter stages of the second-half.
However, it was Bremen who came close to adding a second, after Rosenberg was played in by Pizarro, but took too long to shoot, allowing Contento to get back and make the challenge.
Bayern would find a way back into the game with a quarter of an hour to go, as a surging run by Ribery ended with a cutback into the box that Naldo inadvertently put into his own net.
Ribery almost made another decisive contribution within minutes, but fired just wide of the post after attacking a loose ball into the box. The Frenchman then sent a glorious ball to the far post, that the unmarked Muller really should have turned home, but instead headed over.
Ribery was not to be denied, however, and with one minute remaining in stoppage time, turned his defender on the left before bending a cool finish into the corner to lift the spirits of the Bavarians, for a few hours at least.
Whatever the result at Signal Iduna Park, Bayern will no doubt look to get over it quickly with Madrid to come in their Champions League semi-final second leg in four days.
Bremen, meanwhile, are petering towards a mid-table finish, as their hopes of European football are all but ended for a second straight season