Having weathered the early storm, the visitors started to find their feet, stretching the Frankfurt defence with shots from Alexandru Maxim and Cacau.
Stuttgart continued control the ball, and were able to convert their dominance in possession into an opening goal when a fast break from Maxim set up Martin Harnik for a tap in from close range, while Cacau almost doubled their lead just three minutes later, but a solid save from Kevin Trapp denied the striker.
The visitors continued to look the stronger of the two sides in the second half, as Harnik pushed for his second, before Moritz Leitner pulled his shot just wide.
The hosts started to come back into the match in the final 20 minutes, with Barnetta looking to burst into the Stuttgart box, but his promising run was brought back for offside.
Frankfurt finally got back on level terms in the 80th minute, when Jan Rosenthal slotted the ball in from a Marco Russ header into the box.
Timo Werner almost restored Stuttgart's lead with a powerful header in the 89th minute, but the teenager's effort was well saved.
Frankfurt quickly went on the counter-attack, and managed to grab a late goal when Johannes Flum played the ball through for Alexander Meier, who drilled it in from the centre of the box.
The win moves Frankfurt up to 12th in the table, while Stuttgart sit 15th, just outside the relegation places.