Pep Guardiola will take charge of Bayern Munich on a three-year contract starting next season, the Bundesliga club have confirmed.
Current Bayern coach Jupp Heynckes will stay on in his post until the end of this season before the former Barcelona boss takes over on a deal that runs until June 2016.
Bayern chief executive Karl-Heinz Rummenigge said: "Pep Guardiola is one of the most successful coaches in the world and we are sure that he can make not just Bayern, but all of German football shine."
Guardiola will take over at the German giants on July 1 with Heynckes' contract running out on June 30. The 41-year-old Guardiola announced last April he would be leaving Barca when his contract ran out at the end of the season and would be taking a year-long sabbatical from the game.
A host of clubs had been linked with the Spaniard since he left Barca, including Manchester United, Manchester City and Chelsea in England, Italian giants AC Milan and big-spending Paris St Germain. However, Bayern recently emerged as favourites to capture Guardiola's services.
Guardiola replaced Frank Rijkaard at Barca in 2008 and during his four years at the Nou Camp he led the Catalan giants to 13 trophies, making him the most successful coach in the club's history.
Guardiola's agent Josep Maria Orobitg said the deal to go to Bayern had been signed before Christmas. He also said the offer from Bayern was not the most lucrative they had received, but was the one that appealed most to Guardiola.
"He signed before Christmas. I don't know exactly which day, around the 20th or the second half of December," Orobitg told EFE Radio.
"He chose Bayern because of all the teams from which he had offers it was the best. We were looking over the offers and this isn't the team which offered the most money. It was chosen for the organisation there, for the potential that he sees, and for their players."