The experienced midfielder is set to continue his career with the Bundesliga champion after losing his starting berth at Madrid and will undergo a medical imminently.
The Bundesliga champion was keen to add an extra midfielder to the squad due to the ongoing injury problems of players such as Javi Martinez, Bastian Schweinsteiger and Thiago Alcantara and the club sees the 32-year-old Alonso as a valuable addition.
MORE: Alex Morgan upset at 159-degree temps | Transfer photos
The club was linked with a bid for Athletic Bilbao's Ander Iturraspe this week but has now confirmed it is Alonso who is poised to move to the Allianz Arena, subject to medical tests.
"It is correct that we have been in talks with Real Madrid and Xabi Alonso," Bayern executive board member Jan-Christian Dreesen said at a press conference. "We have basically reached an agreement. The player will arrive in Munich later on Thursday to undergo his medical."
Alonso signed a new contract with Real Madrid until the summer of 2016 earlier this year, but has lost his starting berth with the Santiago Bernabeu side this term as Carlo Ancelotti favours new signing Toni Kroos alongside Luka Modric and James Rodriguez in a three-man midfield.
The midfielder, who announced his decision to retire from Spain duty earlier this week, started his professional career with Real Sociedad and also played for Eibar and Liverpool before joining Madrid in the summer of 2009.
He had since made over 200 official appearances in all competitions for the Bernabeu outfit, but will now continue his career at Bayern.