The former Barcelona boss has been appointed to take over at the Allianz Arena, ending months of speculation over his future.
The 41-year-old former Barca boss left Camp Nou in 2012 having won 14 trophies with the Liga side during his four seasons in charge and has signed a deal with the Bundesliga club until 2016.
Heynckes, who has been boss at Bayern since 2011, told Die Roten officials before Christmas that he would not be continuing in his role beyond the current season, leaving the German side to attempt to secure Guardiola's services.
Guardiola had been linked with a host of top-flight clubs across Europe, but Bayern CEO Karl-Heinz Rummenigge said in a statement he was delighted to have captured the Spaniard.
"We are very pleased that we have succeeded [in appointing] the football expert Pep Guardiola, who was courted by many famous clubs and contacts," said CEO Karl-Heinz Rummenigge.
"Guardiola is one of the most successful coaches in the world and we are sure that he can [help] not just Bayern, but German football, shine."
And Rummenigge praised outgoing Bayern boss Heynckes, adding that securing the Bundesliga crown would be a fitting send off for the German.
"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," he said.
"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, in which we want to get the title to Munich.“
Bayern currently lies top of Germany's top flight, nine points clear of second-placed Bayer Leverkusen.