Julian Nagelsmann is to become the new Bayern Munich head coach and has agreed a five-year contract beginning on July 1, the Bundesliga club announced on Tuesday night (AEST).
Bayern, who are on the verge of a ninth successive Bundesliga title, have agreed to terminate the contract of Hansi Flick, who informed the club he did not want to stay in charge beyond this season.
"Julian Nagelsmann represents a new generation of coaches," Bayern president Herbert Hainer said in a statement.
"Despite his young age, he has had an impressive career. We are convinced that, with Julian Nagelsmann, we will build on the great successes of the past few years."
Talk emerged on Monday that Bayern and Nagelsmann had quickly agreed terms but that a fee to release him from his RB Leipzig contract was proving a sticking point.
According to widespread reports in Germany and Europe, an agreement has been reached between the clubs that would make Nagelsmann the world's most expensive head coach.
The Athletic indicated Bayern will pay around €20 million, while further reports suggest add-ons could take the total closer to €25 million.
Nagelsmann, 33, had also been linked with Tottenham after their decision to sack Jose Mourinho last week.
However, as a boyhood Bayern fan from the Bavarian town of Landsberg am Lech, the Allianz Arena has long been touted as his dream destination.
Nagelsmann, who cost Leipzig a reported €5 million when he joined from Hoffenheim in 2019, has helped to establish the club as Champions League regulars and Bundesliga title challengers.
He guided them to the Champions League semi-finals last season, where they lost 3-0 to Paris Saint-Germain, and a third-place finish in the top flight.
Leipzig are comfortably second in 2020-21 but trail leaders Bayern by seven points with only three games remaining.
Flick, who has been tipped to succeed Joachim Low as head coach of Germany, leaves Bayern after delivering six trophies in under two years, including the treble last season.
Hainer said: "I would like to expressly thank Hansi Flick on behalf of FC Bayern. He took over our team in a difficult phase in 2019 and then won six titles, with the seventh hopefully following soon.
"He will always have a place in the history books of FC Bayern."
Flick said: "The past two years have been unforgettable for me.
"A coach is nothing without his team and I was lucky enough to meet fantastic players and staff here in Munich, and a team of coaches who did incredible things.
"One disappointment remains: that 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 Bayern family the very best for the future. It's not an empty phrase when I say it was a very great honour for me."