Lewandowski snatched his 20th goal of the season after a cutback into the box by fellow Poland international Lukasz Piszczek.
Failure to win at Stuttgart would have given Bayern the chance to clinch the title later on Saturday with a home win over Hamburg SV but second-placed Dortmund's victory put them 17 points behind the Bavarians.
Early substitute Piszczek headed a Marco Reus free kick past goalkeeper Sven Ulreich for the opener in the 29th minute but Dortmund then missed a string of chances.
Stuttgart worked their way back into the game and Alexandru Maxix drew them level with a low drive in the 63rd.
The hosts, who had also hit the post earlier, were lucky to have the goal awarded after Antonio Ruediger stepped well inside the pitch with a throw-in that led to the goal.
Stuttgart then had Georg Niedermeier sent off for a second booking after a rough challenge on Mario Goetze in the 68th and Dortmund made the extra man count when right back Piszczek raced clear down the wing to feed Lewandowski for the tap-in.
- Sports & Recreation