Dortmund are understood to have shelled out €28 million (£25m/$33m) to snare the centre-back, eclipsing their outlay for Henrikh Mkhitaryan but falling short of the €30m (£26m/$35m) spent on Andre Schurrle in 2016.
Diallo impressed in his solitary season for Mainz, making 30 appearances in all competitions following his arrival from Monaco for a reported fee of just €5m.
"Together with my team-mates, I want to justify the trust placed in me and do my part to ensure that BVB achieves its goals in all competitions.
"Now I cannot wait to start preparing for the new season under Lucien Favre."
Dortmund sporting director Michael Zorc said: "Abdou Diallo brings a great deal of what we expect from a defender.
Heute in Dortmund... pic.twitter.com/1N4WKU79Js— Borussia Dortmund (@BVB) June 26, 2018
"He's a modern, strong and very intelligent centre-back, but he can also play on either side of the defence or be used in defensive midfield.
"The combination of his great potential and his versatility made Abdou so interesting for us."
Diallo could prove to be a replacement for Greece international Sokratis Papastathopoulos, who is closing in on a switch to Arsenal.