He has featured in the Champions League and the Europa League while with Dortmund and Leverkusen and played 227 Bundesliga games in total after starting out with Freiburg.
Toprak will play for Werder Bremen on loan in 2019-20, but the two clubs have already agreed a purchase option as part of the deal.
"We'd like to thank Omer Toprak for his commitment and professionalism, and we'd like to wish him every success for his future in Bremen," said BVB sporting director Michael Zorc.
On his move, Toprak added on the Werder website: "I am glad to be here. I had some good conversations with Frank Baumann and Florian Kohfeldt.
"I was convinced by the development and philosophy at Werder and I would like to play my part in contributing to bringing them forward positively."