MUNICH, Germany -- 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 three-year deal on 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.
Rumours 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's arrival is a major coup for Bayern.
"You have to say, hat off," former Bayern star and president Franz Beckenbauer said.
"Matthias Sammer and Guardiola - I don't know where you can find a better partnership," Beckenbauer told Sky television, referring to Bayern's director of sport.
Even Bayern's rivals were impressed.
"A great compliment to Bayern that they have landed this coup," said Hans-Joachim Watzke, the managing director of Borussia Dortmund.
Guardiola's arrival will be good for the entire league, "because the whole world can see that they managed to bring such a coach to Germany," Watzke said.
Guardiola, who turns 42 on Friday, 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, and captured three Spanish championships and two cup titles.
In his first season after being promoted from Barcelona's reserve side, Guardiola won an unprecedented treble, taking the Champions League, Spanish league and Copa del Rey.
"We are very pleased that we managed to win the football expert Pep Guardiola for Bayern Munich 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 lustre not only to Bayern but also to German football."
Guardiola, a former Barcelona midfielder who has never coached outside Barcelona, comes to the most scrutinized club in Germany. Bayern's top management is staffed by some of Germany's biggest past stars, with no small egos.
Bayern is Germany's biggest club, with 21 Bundesliga titles and one championship before World War II.
Bayern president Uli Hoeness said only a coach of Guardiola's calibre could be an adequate replacement for Heynckes, who will be 68 when he retires.
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 also is in the knockout stage of the Champions League, with Arsenal its next opponent.
In the German Cup, Bayern faces Borussia Dortmund in the quarterfinals. Dortmund has won the last two championships and took the double last season.
Heynckes praised his own team in glowing terms last week.
"Bayern has never played such a modern, attractive and contemporary football in its history," Heynckes said.
In Bayern, Guardiola will find Spanish compatriot Javi Martinez, whose transfer was worth (euro)40 million ($53 million). The club's biggest stars are Franck Ribery, Arjen Robben, Manuel Neuer, Philipp Lahm, Bastian Schweinsteiger and Mario Gomez.