Christian Gentner should have put Stuttgart ahead with the first opportunity of the game after beating the offside trap to collect a long ball forward, but he could only drag wide from a promising position.
The miss looked even more important moments later as Frankfurt broke the deadlock through Alexander Madlung, who converted from close range after Haris Seferovic had seen his header come back off the crossbar.
However, Stuttgart would respond impressively to level the scores when Martin Harnik took advantage of a loose ball in the box to slot home the equaliser.
© Getty Images
A fine team move handed the visitors the lead just two minutes later as Sercan Sararer's inviting cross into the box allowed Harnik to tap home his second of the match.
Stuttgart picked up from where they left off after the break as Gentner was given an opportunity to make up for his earlier miss with an emphatic finish from Alexandru Maxim's cross.
However, just at it seemed as though Stuttgart would pull away to record a comfortable win, the hosts hit back in an outrageous three-goal spell either side of the hour mark to get themselves back on level terms.
Alexander Meier reduced the deficit with a calm finish after Stefan Aigner had seen his effort blocked, before Marco Russ provided the perfect cross for Aigner, who took a touch in a crowded box and fired home to make it 3-3 in the 61st minute.
Frankfurt were ahead five minutes later when an inviting free kick from Marc Stendera was met with a slight touch from Madlung, whose second of the game handed the advantage to the hosts for the first time.
They looked set to add more goals as they dominated for a spell after taking the lead, but a late twist left the home supporters shocked.
Stuttgart were not finished there and they secured all three points when a free kick into the Frankfurt box resulted in the ball falling to Gentner, who bundled the winner in from close range.
A remarkable afternoon finished with another disappointment for Frankfurt as Seferovic was shown a straight red card.