Alonso was forced out of Liverpool by manager Rafa Benitez.
The veteran is currently in his third season at Bayern Munich after arriving from Real Madrid on a free transfer back in 2015.
The 35-year-old was a big hit during his time in the Spanish capital, winning the La Liga title, the Copa del Rey and the Champions League.
Xabi Alonso has revealed he nearly joined Barcelona The most surprising transfers in football Thu, October 20, 2016
Express Sport takes a look at some of the most surprising transfers in the Premier League, the Football League and around the world in recent history
Play slideshow Getty Images 1 of 21
Express Sport brings you a collection of the strangest transfers in recent history
However, Alonso has revealed that he nearly joined Pep Guardiola's Barcelona instead.
"It happened not long before I left for Real Madrid," Alonso told French newspaper El Pais.
"Liverpool told me that they wanted to sell me, Rafa Benitez too, and Pep showed an interest in my situation.
"He wanted to sign me because, as he told Rafa, I was the type of player who would fit his [playing] model.
Xabi Alonso went on to be a big hit at Real Madrid
"But he had doubts because Busquets had just come through and had the makings of a tremendous player.
Get Quotes on Home Insurance
"Guardiola chose him, and he wasn't proved wrong."
Alonso is in contention to face Real when the two sides meet in the second leg of their Champions League quarter-final tomorrow.