The Spaniard has been linked with most of Europe’s top clubs since leaving Barcelona at the end of last season.
But Bayern have emerged as favourites in recent weeks, and a statement on the club’s website confirmed his imminent appointment on a three-year deal.
Current boss Jupp Henynckes, 67, told Bayern before Christmas he intends to retire at the end of the season and the club’s directors moved quickly for Guardiola, who has been living in New York on a break from football.
Chief executive Karl-Heinz Rummenigge said: “We are very pleased that we have succeeded in getting Pep Guardiola, who was courted by many famous clubs.
“Pep Guardiola is one of the most successful coaches in the world. We look forward to working with him from July 2013.”