The 20-year-old Leitner, who joined in 2011 from 1860 Munich, struggled to get a regular spot last season in a crowded Dortmund midfield.
"He fits our demands," Stuttgart sports director Fredi Bobic told reporters. "He is young, highly skilled and understands the game very well. He is also capable of playing several positions."
Leitner won the domestic league and Cup double in 2012 and made four appearances in the Champions League last season but was an unused substitute in their 2-1 final defeat by Bayern Munich last month.
Stuttgart have won a spot in the Europa League next season after losing in the German Cup final to treble-winning Bayern.
- Sports & Recreation
- Bayern Munich