The Bundesliga champions have agreed a five-year deal with Nagelsmann after Flick made clear his intentions to quit at the end of the season amid links with the Germany national team manager’s job and an uneasy relationship with the Bavarians sporting director Hasan Salihamidzic.
Flick replaced Niko Kovac as Bayern Munich manager in November 2019 and has won the Champions League, Bundesliga, DFB-Pokal, UEFA Super Cup, FIFA Club World Cup and German Super Cup while in charge of the Bavarians.
"The past two years will be unforgettable for me. I really enjoyed the emotions, the victories, the titles, but also the daily work on the pitch - it was an outstanding time,” the 56-year-old said.
"Success can only be achieved together! A coach is nothing without his team and I was lucky enough to meet fantastic players here in Munich and a staff and a team of coaches that did incredible things. Thank you guys.
"Special thanks also go to president Herbert Hainer, as well as to the entire board of directors around Karl-Heinz Rummenigge, Oliver Kahn and Hasan Salihamidzic for giving me the opportunity to train this great team.
"One downer remains: we weren't able to celebrate the greatest successes during this time with the fans. I've missed them in every game. I wish the FC Bayern family the very best for the future. It is not an empty phrase when I say: It was a very great honour for me."
With Bayern seven points clear in the Bundesliga with just three games to play, Flick is almost certain to add another league title to his list of honours before departing the Allianz Arena.