Niko Kovac's champions knew they needed victory over his former club to stay in touch with Bundesliga leaders Borussia Dortmund, who started the day nine points clear at the top.
Kovac left Frankfurt to join Bayern in the summer, but has come under increasing pressure as his side have fallen off the title pace.
However, the champions' form has picked up of late and on Saturday two goals from 35-year-old Ribery, who looks set to leave Bayern when his contract in the summer, and a lucky late Rafinha effort sealed their fifth successive league triumph and lifted them up to second in the table.
However, the visitors got off to a sluggish start and could have fallen behind on three separate occasions had Frankfurt taken their early chances.
A flowing move down the left got the hosts into the Bayern area as Mijat Gacinovic played in Danny Da Costa, but his effort was saved by the feet of Manuel Neuer.
Sebastien Haller raced into the box but saw his goalbound strike deflected wide by a last-ditch Niklas Sule tackle before Luka Jovic slid an effort just past Neuer's left post in the 10th minute.
Bayern soon worked their way into the match, with David Alaba testing home goalkeeper Kevin Trapp, who tipped the Austrian's effort over the crossbar.
From the resulting corner, Trapp produced a stunning double save, first keeping out a bullet header from Javi Martinez and then, despite still being on the ground, recovering to tip Thomas Muller's header over the bar.
Gacinovic fired over before Frankfurt's profligacy came back to hurt them following a rapid Bayern counter-attack.
Muller latched on to a long pass down the right wing before finding Robert Lewandowski in the area. The Pole's neat turn created a yard of space to get away from marker Simon Falette before fizzing in a low pass for Ribery to tap into an empty net.
Bayern almost doubled their lead on the stroke of half-time, but Muller's luck was out once more as he connected with Lewandowski's cross with a powerful header, only to see the ball rattle the crossbar.
Frankfurt went in search of an equaliser in the second half and missed a series of gilt-edged chances.
Jetro Willems fired well wide from range before the midfielder swung in an inviting cross to the far post which Jovic could not get on the end of.
The hosts' best opening came after 61 minutes when a Jonathan De Guzman corner found Da Costa unmarked in the six-yard box, but his backheeled effort was held by Neuer.
Jovic then fired wide when well placed in the area before Ribery doubled his and Bayern's advantage after finishing off a lovely team move with a calm strike in off a post.
And Rafinha gave the scoreline a harsh look with two minutes left when he mis-hit a right-wing cross intended for Lewandowski and the ball sailed into the top-left corner.