Filip Kostic struck seven minutes from time as Frankfurt secured a first win of the season and first at Bayern since 2000.
Leon Goretzka scored in the first half, but Frankfurt captain Martin Hinteregger quickly hit back.
Bayern, last beaten at home in November 2019, remain top of the Bundesliga, one point ahead of Borussia Dortmund.
They took the lead just before the half hour mark. Goretzka latched on to Robert Lewandowski’s throw ball and steered in his first goal of the season.
Just two minutes later, Hinteregger was left unmarked in the box and powered a header past Manuel Neuer to restore parity.
Frankfurt goalkeeper Kevin Trapp made a superb save from a Lewandowski header 10 minutes after half-time. He then reacted well to save from Serge Gnabry and Leroy Sane, as the home side looked to increase their intensity.
After holding strong, Frankfurt broke through Kostic, who fired a shot past Neuer seven minutes from time – but Trapp was needed again to deny Goretzka in stoppage time.