Pep Guardiola will take charge of Bayern Munich on a three-year contract from the start of 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.
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 and confirmed on Wednesday afternoon they had got their man.
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.
"We are very pleased that we have managed to convince the football expert Pep Guardiola, who was coveted and contacted by many top clubs, to come to Bayern Munich," Rummenigge added.
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.
Heynckes first led Bayern from 1987 to 1991, claiming Bundesliga titles in 1989 and 1990, and returned on an interim basis in April 2009 to guide them into the Champions League qualification spots following the sacking of Jurgen Klinsmann.
Bayern Munich chairman Uli Hoeness added: "Following the decision of Jupp Heynckes, whose work we are extremely grateful for, we would be very happy if the team would give this great coach a glorious farewell.
"Only someone of the calibre of coach Pep Guardiola was an adequate replacement for Jupp Heynckes."
This news does raise fresh questions over who will manage Chelsea next season.
Reports have claimed he was offered a highly lucrative contract to take over at Stamford Bridge when interim manager Rafael Benitez's stint in charge finishes at the end of the season, and it has been confirmed that Guardiola turned down more money from elsewhere to go to Bayern.
Chelsea have never confirmed their interest in Guardiola but his record at Barcelona made him the most sought-after out-of-work coach in world football.
It emerged that Guardiola signed up for Bayern before Christmas.
His agent Josep Maria Orobitg said: I don't know exactly which day, around the 20th or the second half of December."
Speaking on EFE Radio, Orobitg added: "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."
That raised the possibility that a Premier League club had offered big money to Guardiola, although AC Milan and wealthy Paris St Germain had also been credited with interest in him.
Orobitg added: "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."
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.
Since leaving Barcelona last summer, Guardiola has taken a career break and lived in New York, but now Bavaria and the Bundesliga beckons.
"I can imagine that he was overwhelmed by offers," said Franz Beckenbauer, the Bayern honorary president.
Beckenbauer told Germany's Sky Sport News HD: "I have to congratulate Bayern for bringing in Guardiola."
Former England midfielder Owen Hargreaves, who came through the Bayern ranks before joining Manchester United, believes moving to the Allianz Arena was an understandable step.
"Obviously Barcelona, Real Madrid and Manchester United are some of the biggest clubs in the world but Bayern Munich is easily among that top five," Hargreaves said on BBC Radio 5 Live.
"Bayern Munich is the Man United of Germany. They're both the biggest clubs in their countries. Germany is a bigger country than England and with 80 million people it is probably the healthiest league from an economic standpoint in all of Europe.
"I think all things considered it will be a great move for himself. He'll have a great team at his disposal, great resources and the fans are going to love to see what Bayern Munich have to offer in the coming season."
The appointment of Josep Guardiola came as a shock to former Chelsea manager Andre Villas-Boas.
Villas-Boas, now at Tottenham, told CNN World Sport: "I'm so surprised that I asked my media advisor from Tottenham if it was true. Obviously it's a big, big club, one of the biggest clubs in the world, in a league where we didn't maybe expect Guardiola to be in."
Borussia Dortmund managing director Hans-Joachim Watzke said: "I think it's great news.
"I can only congratulate Bayern wholeheartedly and without envy. It's a great story for the league, giving it even more of an international reputation.
"We need to respond to this but not right now, because Borussia Dortmund have the best coach in the world in Jurgen Klopp."