Mazraoui has signed a deal until 2026 with the Bavarian giants who won a 10th straight Bundesliga title this season.
“I’m excited about joining one of the biggest clubs in Europe,” the 24-year-old said in a statement.
“I’ve chosen this club because I can win the biggest titles here.”
Mazraoui, who was born in the Netherlands, will rival France international Benjamin Pavard, who can also play at centre-back, for the right-back place.
He is known as an attacking full-back and he scored five goals this term as Ajax won the Eredivisie title.
“Noussair Mazraoui is the next building block to further strengthen our team and gives us more options,” said Bayern CEO Oliver Kahn.
It was his third Dutch title with Ajax, for whom he made 137 appearances having progressed through their academy.
“He had offers from all over Europe and chose us because we have a clear plan with him and want to achieve big things with him,” said sporting director Hasan Salihamidzic.