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 this 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."
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.
Source: Manchester City MAD