Chinedu Ede gave Mainz the lead after 16 minutes before Stuttgart equalised through own goal by Mainz goalkeeper Christian Wetklo in the 22nd minute.
Arthur Boka then put Stuttgart ahead in the 33rd minute only for Nicolai Muller to equalise for the visitors in the 42nd minute.
Stuttgart, who will face Bayern Munich in the German cup final in Berlin on June 1, finished the season in 12th place with 43 points while Mainz claimed 13th spot with 42 points after ending the season with a nine-game winless drought.
Mainz nearly took the lead in the 10th minute but Andreas Ivanschitz's powerful shot hammered off the underside of the crossbar and bounced back into play.
The visitors took the lead six minutes later as Muller rounded Stuttgart keeper Sven Ulreich to find to the on-rushing Ede, who blasted into the top of the net.
Stuttgart equalised in the 22nd minute thanks to an own goal by Wetklo, who bundled a Martin Harnik cross into his own goal.
Mainz came close to restoring their lead six minutes later as Ivanschitz looped a shot over Ulreich but Georg Niedermeier rushed back to clear the ball off the line.
It was Stuttgart who went ahead in the 34th minute when Boka played a ball to Vedad Ibisevic before receiving it back and smashing it into the far corner.
Mainz equalised in the 42nd minute as Muller's shot barely squeezed past both Niedermeier and Ulreich to cross the line just before a Stuttgart defender could clear.
Mainz nearly put the ball into their own goal again five minutes after the restart as Radoslav Zabavnik deflected an Alexandru Maxim pass off the post, but Wetklo was able to sweep up the ball before it crossed the line.
Ede chipped a ball just off target in the 51st minute for Mainz while Harnik's header sailed wide 22 minutes later.
Muller came close to scoring again in the 79th minute but instead shot wide from 13 yards on the counter-attack, while Raphael Holzhauser's blast from distance veered just inches wide for Stuttgart in the 85th minute.