Ajax academy graduate Gravenberch made his senior debut in 2018-19 and finished with 103 appearances in all competitions, scoring 12 goals.
He won three Eredivisie titles and two Dutch cups with Ajax and has played 10 times for the national side.
"When the offer came from Bayern, I didn't have to think about it for long," Gravenberch said. "Bayern are one of the biggest clubs around; players from all over the world want to play for this club.
"I'm coming to Munich to win lots of titles -- and Bayern are used to winning lots of titles. Anything is possible with this club, including winning the Champions League. The togetherness in this team is strong, which I like."
Bayern won their 10th consecutive Bundesliga crown last season.