The Bundesliga club's financial director Jan-Christian Dreesen said an agreement had been struck "in principle", with Alonso due in Munich later on Thursday for a medical and to discuss terms.
Alonso, 32, emerged as the likeliest central midfielder to leave Real in the wake of Toni Kroos' arrival when the club convinced Sami Khedira to stay at the club last week.
Too cool for Reservoir Dogs
The €32m Spanish youngster Asier Illarramendi only joined Real last year and Luka Modrić, expected to partner Kroos in midfield, recently signed a new long-term contract.
Alonso could become one of an elect number of players to play under José Mourinho and Pep Guardiola if he moves to Bavaria. Samuel Eto'o, Eiður Guðjohnsen, Zlatan Ibrahimović, Cesc Fàbregas and Arjen Robben have previously played for two of world football's eminent coaches.
The loss of Kroos to Real, Javier Martínez's anterior cruciate ligament injury, as well as fitness concerns over Bastian Schweinsteiger and Thiago Alcântara have compelled Guardiola to bolster the Bayern midfield.
Alonso could become the fifth Spaniard at Bayern alongside Thiago, Martínez, his former Liverpool teammate Pepe Reina and Juan Bernat.
On Thursday, Alonso announced his retirement from international football after winning 114 caps. Alonso was in Spain's double-European Championship winning and victorious 2010 World Cup squads.