Pep Guardiola will take charge of Bayern Munich on a three-year contract starting next season, the Bundesliga club has confirmed.
Current Bayern coach Jupp Heynckes will stay on in his post until the end of 2012/13, 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 1 July, with Heynckes' contract running out on 30 June.
Guardiola, 41, announced last April he would be leaving Barça 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 Camp Nou, including Manchester United, Manchester City and Chelsea in England, Italian giants AC Milan and big-spending Paris Saint-Germain.
However, Bayern recently emerged as favourites to capture Guardiola's services and confirmed this afternoon they had got their man.
Guardiola replaced Frank Rijkaard at Barcelona in 2008, and during his four years there led them to 13 trophies, making him the most successful coach in the club's history.
Bayern 'not the team which offered the most money'
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."
Regarding interest from elsewhere and the constant speculation surrounding Guardiola's next step, Orobitg added: "There were contacts with clubs which were close, others which were put on hold until a decision was taken. There have been things coming out from all sides that there had been offers, real meetings, false meetings, trips which didn't exist.
"From Christmas he had to choose his future. All this has been signed for some time. I didn't know that they were going to announce it this afternoon. In fact they informed me at 12 that it was coming out in a statement."