Substitute striker Ansgar Knauff came off the bench to score Dortmund's winner in only his third league appearance.
The 19-year-old, who made his UEFA Champions League debut in the defeat at City after being promoted from the reserves, dribbled clear after Erling Haaland's pass, scoring his first Bundesliga goal.
"It's been an unbelievable week with my Champions League debut and first Bundesliga goal," Knauff said. "I hope things keep going so well."
This was Haaland's sixth game without a goal for club or country, but he did claim two assists.
The visitors were 1-0 down at half-time, but after Jude Bellingham equalised, Haaland left the ball for Marco Reus to put Dortmund 2-1 up.
Daniel Didavi fired Stuttgart level before Knauff hit the winner 10 minutes from time as Dortmund avenged its 5-1 thrashing at home by Stuttgart last December.