Pep Guardiola, who led Barcelona to 14 titles over four seasons and turned the Spanish club into arguably the best team in the world, has agreed to become the coach of Bayern Munich starting next season.
Bayern announced the deal Wednesday, after a meeting of the top management.
Earlier in the day, Jupp Heynckes told Bayern he wanted to end his coaching career when his contract expires at the end of the season.
Rumors of Guardiola coming to the German powerhouse have been swirling around local media for weeks and Bayern made it official just a day after Guardiola expressed his desire to manage in England at some point.
Guardiola stepped down at the end of last season and is on a one-year sabbatical.
Under his guidance, Barcelona dominated Spanish and European competitions with its passing game and frequent scoring from standout Lionel Messi.
Barcelona won the Champions League twice during Guardiola's tenure, in 2009 and 2011.
''We are very pleased that we managed to win the football expert Pep Guardiola for Bayern Muinich although he had been contacted and sought by many famous clubs,'' Bayern chairman Karl-Heinz Rummenigge said. ''Pep Guardiola is one of the most successful coaches in the world and we are certain that he can give a lot of luster not only to Bayern but also to German football.''
Bayern President Uli Hoeness said only a coach of Guardiola's caliber could be an adequate replacement for Heynckes.
Bayern lost the Champions League final last season to Chelsea and has failed to win a trophy in the past two seasons. But it has a large lead in the Bundesliga this season, which resumes this weekend. Bayern is nine points ahead of Bayer Leverkusen .
Bayern revealed Guardiola's move had been in the pipeline since at least before Christmas, when 67-year-old Heynckes informed the club he would not be seeking an extension to his existing contract and would instead retire.
Rummenigge backed Heynckes to continue to excel in his final months as coach, having guided Bayern to a nine-point lead in the standings ahead of the Bundesliga's resumption following the winter break this weekend.
"As a club and as Jupp Heynckes' friends we have to show understanding for this decision. We have to accept it and we have to respect it," Rummenigge added.
"During personal talks with Jupp Heynckes we assured each other that we will do anything we can, and now even more, to have a successful second half of the season 2012/13 where we want to get the title to Munich."
Heynckes is in his third spell at Bayern after returning to the club in June 2011.
Although he failed to prevent Borussia Dortmund winning their second successive Bundesliga title last season, he did guide the Bavarians to the Champions League final in May, when his charges were defeated by Chelsea on penalties in front of their home fans in Munich.
"Only someone of the calibre of coach Pep Guardiola was an adequate replacement for Jupp Heynckes."
Guardiola came up through the youth ranks as a player at home-town club Barcelona before making his senior debut in the 1990/91 season and going on to captain the side. During 11 seasons in the first team, the classy midfielder made 472 appearances and helped the club win a host of trophies, including Barca's first European Cup title, six league crowns, the European Cup Winners' Cup, and two Copa del Reys.
After leaving Barca in 2001, Guardiola played for Italian sides Brescia and Roma and also had stints in Qatar and Mexico before hanging up his boots in November 2006.
He was named as the coach of Barcelona B in 2007, but spent only a year at the helm before being promoted to replace Rijkaard, who left in the summer of 2008 after going two years without a trophy win.
Under Guardiola, Barca established themselves as the dominant force in club football, with many rating the team as the best in history. Boasting the likes of Lionel Messi, Xavi and Andres Iniesta, Barca won two Champions League crowns, three La Liga trophies, one Copa del Rey, three Supercopas, two UEFA Super Cups and two FIFA Club World Cups during Guardiola's tenure.
The Associated Press contributed to this report.